Reputation: 281
I have a couple of tables with special names that I imported through a SQL file (this is required, it's for school, all tables must have our initials before the actual table name), I have seen that most of the tables through Laravel are created with a migration, I want to use Eloquent for the CRUD but I don't want to use migrations, what's the approach for it? what should I investigate to make this? I'm a bit confused.
Upvotes: 1
Views: 572
Reputation: 733
Inside your model you can define the table for that model. for example if you have a table named a_school, in the A_SchoolModel.php you can define the table as below.
protected $table = 'a_school';
Also if the database engine for app is InnoDB, go to config->database and set mysql => [ 'engine' => 'innoDB',]
Upvotes: 1
Reputation: 8618
In laravel migrations need for make your databse easly. If you already make database you can use Eloquent model like this
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class School extends Model
{
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'school';
}
https://laravel.com/docs/6.x/eloquent#eloquent-model-conventions
Upvotes: 1