Skip to content
This repository has been archived by the owner on Sep 12, 2022. It is now read-only.

Commit

Permalink
Check if $value isn't empty
Browse files Browse the repository at this point in the history
  • Loading branch information
FaZeRs committed May 4, 2019
1 parent d767557 commit ca054eb
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions app/Models/Project.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,14 @@ public function setLinksAttribute($value)
{
$this->links()->delete();
$links = [];
foreach (json_decode($value) as $link) {
$links[] = new Link([
'title' => $link->title,
'url' => $link->url,
'icon' => $link->icon,
]);
if(json_decode($value)) {
foreach (json_decode($value) as $link) {
$links[] = new Link([
'title' => $link->title,
'url' => $link->url,
'icon' => $link->icon,
]);
}
}
if ($links) {
$this->links()->saveMany($links);
Expand Down

0 comments on commit ca054eb

Please sign in to comment.