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

I also tried

$membership_user = new MembershipUser;

and also

$membership_user = new membership_user;

But it is not working and the error message is that such class was not found ;(

In my models folder I have a file membership_user.php and this code:

<?php

class Membership_user extends \Eloquent {

	protected $table = 'membership_user';

}

But I get still the wrong error messsage

Any idea?

Last updated 9 years ago.
0
Solution

I am not sure whether the naming convention is a mandatory rule and still valid, but class names must be studly caps. http://www.developed.be/2013/08/21/laravel-naming-conventions/

Thus, try using class name 'MembershipUser' and the file name 'MembershipUser.php'. If you use the same name for the file and class, you'll also avoid unnecessary problems.

Anyhow, if that does not work, I'd suggest to do a

composer dump-autoload
0

Thanks for the suggestion goedda. It worked!

I have changed the model file name from Membership_user.php to MembershipUser.php and the calss name from Membership_user to MembershipUser and now it is finally working ;)

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.