I want to check if the model has been changed with isDirty method, but always returns false.
This is my code :
if (!is_null($partnersData)) {
foreach ($partnersData as $partnerData) {
$partner = Partner::find($partnerData['partner_id']);
$partner->update($partnerData);
if($partner->isDirty()){
dd('true');
}
}
}
via Chebli Mohamed
it works with save() method :
RépondreSupprimer-----------------------
if (!is_null($partnersData)) {
foreach ($partnersData as $partnerData) {
$partner = Partner::find($partnerData['partner_id']);
foreach ($partnerData as $key => $value) {
$partner->$key = $value;
}
if($partner->isDirty()){
//your code here
}
//then save your values
$partner->save();
}
}