0

I am making a web app on Laravel 5.3 which is frontend app. I am managing data from a Backend App. I have already made models and migrations in the frontend app and not in the backend app. So how should I use same database, models and migrations for both. Please help.

4 Answers 4

1

You can just create the models in the backend app and they will still work.

If you are using Artisan:

php artisan make:model ModelName

Migration files can be a little more tricky, I would suggest just managing all of this through your frontend app for consistency and then creating the models you need in the backend app.

Sign up to request clarification or add additional context in comments.

Comments

0

You didn't mention if your backend app is also using Laravel.

Either way, I think your best approach would be to structure the backend app as an API. Then it would contain the database migrations and models. The back end would be the one to connect directly with the database. The front end would then fetch the data from the back end API and display them. The front end app could then have its own models too (but not database models).

Comments

0

There are arguments to support both using an API on the front-end app to access the backend or just recreating the models on each system. I'm supporting multiple sites which access the same data. It soon became apparent that the best way was to create an API on the backend to service them all. Also worked for other shared resources i.e. images.

There is a slight penalty in the load times but is so small it isnt worth noting. It also helped when using other platforms i.e. ioS, android and Ajax.

Comments

0

You can rename the migrations table in your bootstrap/app.php like this:

$app->configure('database');
$app->config->set('database.migrations', 'backend_migrations');

That way you will get two migration tables, one for the frontend, and one for the backend all in the same database.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.