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)) {
$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:
$partner = Partner::find($id);
foreach ($partnerData as $column => $value) {
if ($column === 'id') continue;
$partner->$column = $value;
}
if ($partner->isDirty()) {
// should be dirty now
}
$partner->save(); // $partner will be not-dirty from here