The question might sound vague but in fact, it's something I've been wondering for some time and I don't know how can I do it.
I've been working with Laravel 5 for a while, but most of the projects I've developed using Laravel, have the frontend app and the backend app in the same project This time the requirement is to make two separate projects, one for the frontend, and the other one for the backend.
The inquiere comes up when trying to figure out how will the controller interact with the Model, and how will the migrations be handled? Will I have to make a model for each table in both the frontend and the backend?
The goal is to use the same database for both projects, without having problems with the migrations and the models.
EDIT 1 What i mean by Frontend App is the website where the data will be displayed, where people will interact, where they will see something. The Backend App is the one where the admins will edit the content of the frontend, where they will be able to CRUD to the database; in the frontend app i just want to select data from db.
What assumption from your question is, your backend will insert, update, delete or do any other query to your database and your frontend will be responsible for controlling forms, pages and showing data. With this model, if you want to use the same Models and migrations, you'll actually not need to create separate projects for backend and frontend. I've managed to separate the backend (api/v1) and frontend in same projects using separated routes. I'll describe it bellow.
Folder Structure
For my backend controllers, I've put them in
api/v1
folder. For each controller inapi/v1
folder, use the namespaceApi\V1
like this.Now to call all of your backend api using router, use route group. Example:
Now call your backend api controllers from anywhere in your projects. Your api can use any model in your projects and obviously your other main controllers will work as your frontend controller and you can do all regular stuffs.