How to create Models in Laravel from tables already created in the Mysql database

Asked

Viewed 1,909 times

0

Good morning guys, I have a question in Laravel, I had a database created in Mysql and use Xethron/Migrations-Generator to create the Migrations from the tables created in the database, but how can I generate the Models in Laravel from the Migrations that are created?

inserir a descrição da imagem aqui

1 answer

2


Daywison, I’m not sure I understand.

You would like to create the models from a command that automatically generates the models or the question is how to create the models with the names of the existing tables.

If it is the first option follow a package that you can use https://github.com/reliese/laravel . If it is the second option follow the code snippet:

 
namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class ProductPeople extends Model
{
    // Nome da tabela existente
    protected $table = 'fornecedores';

}

I believe it’s the first, but I’ve put both options in case anyone needs it. ;)

I hope I’ve helped!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.