What is the error you get?
Nov 30, 2015
3
Level 4
first element of object in blade
My products can belong to many categories. I use a category slug as part of the url. in my dashboard im trying to create a link to edit the product page so based on $product having multiple categories I want it to use the first result.
In Tinker the following works
$product->categories{0}->slug
However it doesn't in my view which I assume is to do with curly braces and blade.
{{ URL::route('product.edit', ['cat_slug' => $product->categories{0}->slug , 'slug' => $product->slug]) }}
The following also throws an error yet is ok in tinker
$product->categories->first()->slug
ErrorException in 9f71a027c69fcef767e74df068f0e9c7 line 50: Trying to get property of non-object (View: /volume1/web/laravel/resources/views/admin/products.blade.php)
Please or to participate in this conversation.