I'm trying to do a CRUD with Eloquent Laravel in 2 tables with FK and PK, but I'm not having success, since the models only lack the CRUD function, can anyone help me?
This is model with FK:
class crud_consignado_acordo extends Model
{
protected $fillable = [
'cpf',
'valor',
'formaenvio',
'datavencimento',
'numerocontrato',
'id_consignado_registro',
'id'
];
protected $table = 'tb_consignado_acordo';
public function registro()
{
return $this->belongsTo(crud_consignado_registro::class, 'id_consignado_registro');
}
}
E esta com a PK:
class crud_consignado_registro extends Model
{
protected $fillable = [
'produto',
'datareg',
'nomeoperador',
'celula',
'usuariox',
'aspect',
'supervisor',
'hora',
'id'
];
protected $table = 'tb_consignado_registro_operador';
public function acordo()
{
return $this->hasMany(crud_consignado_acordo::class, 'id_consignado_registro');
}
}
The question is how to do CRUD with Eloquent Laravel ORM in these tables.