Skip to content

Commit

Permalink
Fix eloquent redirects not updating (#160)
Browse files Browse the repository at this point in the history
  • Loading branch information
vluijkx authored Jan 16, 2024
1 parent d2f3d61 commit 52cde06
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/Eloquent/Redirects/RedirectRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,16 +103,22 @@ public static function fromModel(Model $model)

private function toModel(Redirect $redirect)
{
return RedirectModel::firstOrNew([
'id' => $redirect->id(),
], [
$properties = [
'source' => $redirect->source(),
'destination' => $redirect->destination(),
'match_type' => $redirect->matchType(),
'type' => $redirect->type(),
'enabled' => $redirect->enabled(),
'order' => $redirect->order(),
'site' => $redirect->locale(),
]);
];

$model = RedirectModel::firstOrNew(['id' => $redirect->id()], $properties);

if ($model->exists) {
$model->fill($properties);
}

return $model;
}
}

0 comments on commit 52cde06

Please # to comment.