toto01
toto01

Reputation: 153

Database without migration using Laravel 5.4l

I created a database in phpMyAdmin and I want to use it in my project in Laravel without going through the migration. will I need the models? and how can I make the CRUD operations without using the models? if I need the models how can I connect each model with its table ?

Upvotes: 0

Views: 3258

Answers (1)

Daniel
Daniel

Reputation: 2777

You don't need to use migrations with your database. Even, you don't have to use models to use CRUD - you can use Query Builder. But, if you want to get all the power of CRUD - models are recommended. Models are "auto-connected" to DB by their names. If you have model Product it will be "connected" to products table.

If your database structure have different names you can define your table directly in model class:

Example of model Product in Product.php:

class Product extends Model {
    protected $table = 'my_custom_products_table';
}

Upvotes: 2

Related Questions