Comment puis-je insérer des données (qui se lient mutuellement) à la table 'PEMBATALAN' qui a une relation un à un (avoir une clé étrangère dans les deux tableaux) à l'autre table 'PERMINTAAN' .Laravel insérer des données dans une table de relation un à un
ici est le code du modèle 'pembatalan':
class Pembatalan extends Model
{
public $table = "PEMBATALAN";
public $primaryKey = "ID_PEMBATALAN";
public $fillable = array(
'PERMINTAAN_ID',
'ALASAN_PEMBATALAN',
'TGL_PEMBATALAN',
'FILE_PEMBATALAN',
'STATUS_PEMBATALAN',
);
public function permintaan() {
return $this->belongsTo('Permintaan', 'PERMINTAAN_ID', 'ID_PERMINTAAN');
}
}
code modèle 'Permintaan':
class Permintaan extends Model
{
public $table = "PERMINTAAN";
public $fillable = array(
'NOMOR_TICKET',
'TGL_PERMINTAAN',
'NAMA_REQUESTER',
'PEMBATALAN_ID',
);
public $primaryKey = "ID_PERMINTAAN";
public function tikpro() {
return $this->belongsToMany('Tikpro','TIKPRO_ID','ID_TIKPRO');
}
public function pembatalan() {
return $this->hasOne('Pembatalan','PEMBATALAN_ID','ID_PEMBATALAN');
}
}
Merci à l'avance