i trying pass variable view output in doing following error thrown: undefined variable: property (view:
i know error because variable not being picked in view don't know why here code
controller $property defined:
<?php namespace app\http\controllers; use datatable; use view; use app\models\ec2instance; use app\models\changedproperties; use illuminate\support\facades\input; use app\models\changelogitem; class detailscontroller extends controller { protected $layout = 'ec2_instance'; public function changedproperties($resource_id, $resource_type) { $changed_property = new changedproperties; $changed_properties = $changed_property->where('resource_id', $resource_id)->where('resource_type', $resouce_type); } public function details($instance_id) { $instance = new ec2instance; $instance_obj = $instance->where('instance_id', $instance_id)->first(); $property = new changelogitem; $properties = $property->where('resource_id', $instance_obj->id)->where('resource_type', 'ec2instance'); // $table = datatable::table() ->addcolumn( 'changed property', 'change type', 'previous value', 'updated value' ) ->seturl('/ec2_instance/ec2instance/' . $instance_obj->id) ->noscript(); return view::make('ec2_instance')->with('instance', $instance_obj, $properties)->with('table', $table); } public function instance_details($resource_type, $resource_id) { $query = changelogitem::select(array('message_id', 'type', 'changelog_item_id', 'created_at', 'updated_at', 'description')) ->where('resource_id', $resource_id)->where('resource_type', $resource_type)->get(); return datatable::collection($query) ->addcolumn('message_id', function($model) { $link2 = "<a href = '/changed_properties/" . $model->message_id . "' >" . $model->message_id . "</a>"; return $link2; }) ->showcolumns( 'message_id', 'type', 'changelog_item_id', 'created_at', 'updated_at', 'description') ->searchcolumns('message_id', 'type', 'changelog_item_id', 'created_at', 'updated_at', 'description') ->ordercolumns('message_id', 'type', 'changelog_item_id', 'created_at', 'updated_at', 'description' ) ->make(); } } and view
<!doctype html> <html lang="en"> <head> <title>instance details </title> {!!html::style("css/jquery.datatables.css")!!} {!!html::script("js/jquery.js")!!} {!!html::script("js/jquery.datatables.min.js")!!} <meta charset="utf-8"> <title>config search</title> <style> @import url(//fonts.googleapis.com/css?family=raleway:700); body { margin:0; font-family:'raleway', sans-serif; text-align:center; color: #3a3a3d; } .welcome { width: 300px; height: 200px; position: absolute; left: 50%; top: 50%; margin-left: -150px; margin-top: -100px; } a, a:visited { text-decoration:none; } h1 { font-size: 32px; margin: 16px 0 0 0; } </style> </head> <body> <div class="navigation-left" style="float:left"> <a href="{!! url('/') !!}">back </a> </div> <div class="row"> <div class="col-md-12"> <h3>instance details {!! $instance->instance_id !!}</h3> <script language="javascript"> function formatasukdate(date) { var date = new date(); var day = padwithzero(date.getdate(), 2); var month = padwithzero(date.getmonth() + 1, 2); var year = date.getfullyear(); var hour = date.gethours(); if (hour <= 9) hour = '0' + hour; var mins = date.getminutes(); if (mins <= 9) mins = '0' + mins; return day + '/' + month + '/' + year + ' ' + hour + ':' + mins; } function padwithzero(str, minlength) { str = string(str); while (str.length < minlength) { str = '0' + str; } return str; } document.write("last refreshed: " + formatasukdate(document.lastmodified) + ""); </script> </div> <table> <tr><th>instance id</th><td>{!! $instance->instance_id !!}</td></tr> <tr><th>image id</th><td>{!! $instance->image_id !!}</td></tr> <tr><th>private dns name</th><td>{!! $instance->private_dns_name !!}</td></tr> <tr><th>public dns name</th><td>{!! $instance->public_dns_name !!}</td></tr> <tr><th>key name</th><td>{!! $instance->key_name !!}</td></tr> <tr><th>instance type</th><td>{!! $instance->instance_type !!}</td></tr> <tr><th>launch time</th><td>{!! $instance->launch_time !!}</td></tr> <tr><th>kernel id</th><td>{!! $instance->kernel_id !!}</td></tr> <tr><th>subnet id</th><td>{!! $instance->subnet_id !!}</td></tr> <tr><th>vpc id</th><td>{!! $instance->vpc_id !!}</td></tr> <tr><th>private ip address</th><td>{!! $instance->private_ip_address !!}</td></tr> <tr><th>public ip address</th><td>{!! $instance->public_ip_address !!}</td></tr> <tr><th>architecture</th><td>{!! $instance->architecture !!}</td></tr> <tr><th>root device type</th><td>{!! $instance->root_device_type !!}</td></tr> <tr><th>root device name</th><td>{!! $instance->root_device_name !!}</td></tr> <tr><th>virtualization type</th><td>{!! $instance->virtualization_type !!}</td></tr> <tr><th>source dest check</th><td>{!! $instance->source_dest_check !!}</td></tr> </table> </div> <table <tr><th>message id</th><td>{!! $property->message_id !!}</td></tr> <tr><th>type</th><td>{!! $property->type !!}</td></tr> <tr><th>changelog item id</th><td>{!! $property->changelog_item_id !!}</td></tr> <tr><th>created</th><td>{!! $property->created_at !!}</td></tr> <tr><th>updated</th><td>{!! $property->updated_at !!}</td></tr> <tr><th>description</th><td>{!! $property->description !!}</td></tr> </table> {!! $table->render() !!} {!! $table->script() !!} </body> </html> $instance found yet $property not.
it's because not passing in view take here
return view::make('ec2_instance')->with('instance', $instance_obj, $properties)->with('table', $table); i think should this
return view::make('ec2_instance') ->with('instance', $instance_obj) ->with('property', $property) ->with('table', $table); also not seem fetching database here
$properties = $property->where('resource_id', $instance_obj->id)->where('resource_type', 'ec2instance'); this query should end first() method if want instance returned
or get() if want collection returned.
Comments
Post a Comment