Laravel project using Models External

Laravel Project using External Models

I need to use a structure in the Laravel Project where the Models were in an external LIB, being used as dependency of the project. I tried different ways and I still did not succeed.

Any idea how I can do it?

Mubassir Hayat replied 11 months ago

If the dependency is laravel compatible and you have added the service provider the dependency in the providers' array then you can easily access the models by using their namespace.

Here is what I would suggest. Create a model for your app and extend that model from the model in the dependency that way if the dependency is updated you won't have to worry about it and you can attach your methods the extended model.

Jeremias Santos replied 11 months ago

Still can not make it work. I would like to have the models in a separate project in a Lib so I can use it in other projects, but I have not found how to map the classes in Laravel to reconnect the models as BD entities. I created the lib using Eloquent as depedence, but I'm having difficulty configuring for the Laravel application to recognize it as depedence.

Mubassir Hayat replied 11 months ago

Will be happy to help if you post some details. Like what package you are using and the way you have extended your model.

Sign in to participate in this thread!

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