add thumbnail cover on memo

This commit is contained in:
2020-05-17 19:23:50 +02:00
parent 0034fdbbc4
commit aae3dba36e
4 changed files with 40 additions and 1 deletions

View File

@@ -41,4 +41,14 @@ class Memo extends Model
$userImage->path = 'images/default-cover.jpg';
});
}
public function thumbnailImage(): MorphOne
{
return $this->morphOne(Image::class, 'imageable')
->orderBy('id', 'desc')
->where('location', 'cover-small')
->withDefault(function ($userImage) {
$userImage->path = 'images/default-cover.jpg';
});
}
}