php - Trying to get property of non-object in controller -
this controller
public function show($restaurant_id) { $data = restaurant::find($restaurant_id)->waitingtimes(); echo $data->first()->value; exit;
i got trying property of non-object
though waitingtime
model mapped database table has value
column.
could help please? also, tell me can read documentation returning type of function find()
thanks
the info not empty; can see database, , restaurant
table has id 20 , table waitingtimes has values restaurant_20
20
actually - improve map route model.
so in routes.php file:
route::model('restaurant', 'restaurant'); route::get('/restaurant/{restaurant}', ['as' => 'restaurant.show', 'uses' => restaurantcontroller@show]);
then in controller file:
public function show(restaurant $restaurant) { echo $restaurant->waitingtimes()->first()->value; }
you can read more route model binding here.
php laravel laravel-4 blade
No comments:
Post a Comment