Abdur Rahman
Abdur Rahman

Reputation: 783

Dynamic model namespace in laravel lumen package

I am building a laravel lumen package. In the package there is a service provider which uses instance of User model in a function. I used App\User as namespace there.

Now, If actual User Model is placed in different namespace eg. App\Models\User my package gives an error of undefined class User.

How can I get this User model instance in proper way without any error?

Upvotes: 3

Views: 411

Answers (1)

Jerodev
Jerodev

Reputation: 33186

You could get the User model location from the config/auth.php. However if the application uses a different authentication method, this will not work.

I think your best option is to make the class path to the User model configurable.

Upvotes: 1

Related Questions