As Migrations are required if you are going to create or modify tables in the dataset.
To manipulate these tables, you can Query Builder, that is, without the need for a Model
, for example:
$users = DB::table('users')->get();
$user = DB::table('users')->where('name', 'John')->first();
DB::table('users')->where('id', 1)->update(['votes' => 1]);
If you need the Model
in its implementation, it is good to point out that the Model
Laravel has settings by default, for example, the table name, which column is primary key and whether the table has columns created_at
and updated_at
. Tables created outside the standards are required to specify. When in doubt, look at the documentation of Eloquent.
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Pessoas extends Model{
protected $table = 'pessoas';
protected $primaryKey = 'id_pessoa';
public $timestamps = false;
}