I'm actually making a laravel CRUD app.
So there is this model called User which has been created, but when I try to use it in a controller (In this case, HomeController.php), it says:
Here is line 28 from the controller:
I'm sorry if this question already exists but I've searched everywhere for a solution but could not find it.
Thank you.
Ideally, you should post the line you are importing the model, and the first few lines of your model. But I will try to explore the possibilities of error.
Is your model inside a specific folder (just like app/MyModels/User.php) or just inside the default place when you use
php artisan make:model? Remember to put the exact path innamespaceline inside of model.In the first line of your model you should have the path of your model with namespace. If the model is in its default directory, you should have the line below, but if it is inside of a folder, you have to put the folder path after de App:
Verify if you model is
extendsofModel:In your controller the
useline have the same path of namespace line in model, if you model is in default path, should be like this:Remember that: the
Appis the namespace of your project, if you used thephp artisan app:namecommand your namespace is no longer anApp, and you should change it if you have the old name somewhere. If you using linux, remeber of the case sensitive.If it does not work, put into the post the codes of the files I've listed so we can help.