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');
}
}
}
$model->update()
updates and saves the model. Therefore,$model->isDirty()
equals false as the model has not been changed since the last executed query (which queries the database to save the model).Try updating the model like this: