Support the ongoing development of Laravel.io →
Database Eloquent
Last updated 2 years ago.
0

There is already a model called User.php in your models directory, it contains the boilerplate you need.

Last updated 2 years ago.
0

Thanks, I actually tried that one before but it also shows "Class 'Eloquent' not found", that's why I was trying to follow the laravel documentation to create one from scratch... Why is that happening?

Last updated 2 years ago.
0

Can you please copy and paste your code in here from your model (use the code markup or a pastebin), that would make it easier :)

Last updated 2 years ago.
0

Pastebin would be great, thank you

Last updated 2 years ago.
0

I have never encountered a similar problem. And you did not modify your installation in any way besides setting up your database connection?

Last updated 2 years ago.
0

Please delete the file you created yourself, and just use the one that was supplied with the installation, it should work with no problem tbh.

Im talking about the User.php in Models.

Last updated 2 years ago.
0

I also added a folder with some static html files inside the "public" folder and that's all... yes this does sounds strange.

Yes I deleted the another file and uses the original User.php that comes with the installation, and the error is the same...I have tried clearing cache and things like that as well...

Last updated 2 years ago.
0

Could you maybe try doing a completely fresh installation? I'm also curious about your setup, are you using Homestead or some other Vagrant box?

Last updated 2 years ago.
0

Yes I am creating a new laravel project right now, will report back when it's done. Im just using XAMPP and composer.

EDIT: Oh no, a fresh project creation gives me the same error...

Last updated 2 years ago.
0

How are you creating your project?

Last updated 2 years ago.
0

composer create-project laravel/laravel --prefer-dist in command prompt

Last updated 2 years ago.
0

Try putting a backslash "" before Eloquent

class User extends \Eloquent implements UserInterface, RemindableInterface {

Also do you still have it in app/models directory?

Last updated 2 years ago.
0

Thanks, yes the User.php is still in the app/models. But adding the backslash does not work for me unfortunately...

Last updated 2 years ago.
0

Hi larahub, did you solve your problem ? I've got the same issue ! Please let me know :)

Last updated 2 years ago.
0

Try maybe to check if : Illuminate\Database\Eloquent\Model exist in the vendors folder and check app/config/app.php if there is a eloquent aliases...

Eventually make a :

composer dump-autoload and php artisan dump-autoload ?

Last updated 2 years ago.
0

Hi and Thanks for your answer :

So first of all, i have this in my vendor :

vendor\laravel\framework\src\Illuminate\Database\Eloquent

And in app/config/app.php i have :

'Eloquent' => 'Illuminate\Database\Eloquent\Model',

Then, i just tried to do composer dump-autoload & artisan dump-autoload at the root of my project.

But i still have :

Fatal error: Class 'Eloquent' not found in C:\wamp\www\Alpha\app\models\User.php on line 8

Last updated 2 years ago.
0

Did you try to include a direct ref in your User model like :

use Illuminate\Database\Eloquent\Model as Eloquent;

Seems to be a problem of autoload maybe issue with DOCUMENT_ROOT path config of your Wamp install...

Last updated 2 years ago.
0

This worked very well in my case. Thanks a lot.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.