0

I made php artisan migrate:fresh in my Laravel application but when i creating a new user I got this error

Trying to get property 'courses' of non-object (View: /Applications/AMPPS/www/zenit/resources/views/home.blade.php)

I have a table called courses which is empty. How can I solve this?

shudder
  • 2,076
  • 2
  • 20
  • 21
Tianma1970
  • 59
  • 1
  • 4

1 Answers1

0

php artisan migrate:fresh is used for dropping and creating all the tables again. You are trying to access an object that is not fetched. Please check you method where home view is used. At that place check the response and also use dd($database_response) for getting reponse in browser. hope that it will help you

Ariful Islam
  • 696
  • 6
  • 11
  • Ok I think the problem might be that I try to get courses in the controller which don't exists. I send $courses = Course::orderBy('title')->get(); to the view. How can I define the variable $courses if there are no courses as in my case? – Tianma1970 Apr 11 '20 at 16:29