我的 Laravel blade 有变量问题
Problem in my Laravel blade with variables
我的 blade 有问题。当我 运行 我的项目时出现此错误:
我的blade代码:
@foreach(\App\Category::all()->where('parent' , $product->categories->where('parent' , '0')->first()->id )->first() as $category)
<option data-id="{{ $category->id }}" value="{{ $category->id }}" {{ in_array($category->id , $product->categories->pluck('id')->toArray()) ? 'selected' : '' }}>{{ $category->name }}</option>
@endforeach
并显示错误:
ErrorException
Trying to get property 'id' of non-object (View: F:\Projects\Laravel Projects\NilfamShop\laravel\resources\views\admin\products\edit.blade.php)
这可能是错误的:
$product->categories->where('parent' , '0')->first()->id )->first()
也许你可以打电话:
$product->categories->where('parent' , '0')->first()->id
我的 blade 有问题。当我 运行 我的项目时出现此错误:
我的blade代码:
@foreach(\App\Category::all()->where('parent' , $product->categories->where('parent' , '0')->first()->id )->first() as $category)
<option data-id="{{ $category->id }}" value="{{ $category->id }}" {{ in_array($category->id , $product->categories->pluck('id')->toArray()) ? 'selected' : '' }}>{{ $category->name }}</option>
@endforeach
并显示错误:
ErrorException
Trying to get property 'id' of non-object (View: F:\Projects\Laravel Projects\NilfamShop\laravel\resources\views\admin\products\edit.blade.php)
这可能是错误的:
$product->categories->where('parent' , '0')->first()->id )->first()
也许你可以打电话:
$product->categories->where('parent' , '0')->first()->id