Open KhasanLaudry opened 2 years ago
Same here.
How did you resolve it please? I've encountered the same error here!
Sir @laraveller kindly help us!
same
It is simple just before the foreach
you will add this line @if(!is_null($specials))
The final code is:
@if(!is_null($specials))
@foreach ($specials->menus as $menu)
<div class="max-w-xs mx-4 mb-2 rounded-lg shadow-lg">
<img class="w-full h-48" src="{{ Storage::url($menu->image) }}" alt="Image" />
<div class="px-6 py-4">
<h4 class="mb-3 text-xl font-semibold tracking-tight text-green-600 uppercase">
{{ $menu->name }}</h4>
<p class="leading-normal text-gray-700">{{ $menu->description }}.</p>
</div>
<div class="flex items-center justify-between p-4">
<span class="text-xl text-green-600">${{ $menu->price }}</span>
</div>
</div>
@endforeach
@else
<div>No item was found</div>
@endif
Thank you guys!
Fix for ---> "menus" on null'.
You need a category
named Specials
.
Use below sql statement:
INSERT INTO
categories(
name,
description,
image,
created_at,
updated_at) VALUES ('Salads', 'Best Salads', 'public/categories/g9KVcF1CNYHhz10DepRga3Qln6Cuen8NsTL0YLRT.jpg', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), ('Specials', 'Today\'s Specials Menu', 'public/categories/JtbQlbhxQZfPIofqpc4X1KEQ3D6UxqCaALzxYgXd.png', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP);
Note: Change the images with your own uploaded or keep it blank and use the below instead.
INSERT INTO
categories(
name,
description,
created_at,
updated_at) VALUES ('Salads', 'Best Salads', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), ('Specials', 'Today\'s Specials Menu', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP);
Hope this helps.
after clonning the repo and setting everything up, I run
php artisan serve
, I encounter errorAttempt to read property "menus" on null
on homapage welcome.blade.php line 124