WIP
This commit is contained in:
@@ -5,12 +5,26 @@ namespace App\Models;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
class Album extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
public function category() : BelongsTo {
|
||||
$this->belongsTo(Category::class);
|
||||
return $this->belongsTo(Category::class);
|
||||
}
|
||||
|
||||
public function images() : HasMany {
|
||||
return $this->hasMany(Image::class);
|
||||
}
|
||||
|
||||
public function media() : Collection {
|
||||
return $this->images;
|
||||
}
|
||||
|
||||
public function getThumbnailAttribute() : ?string {
|
||||
return $this->images()->where('isCover', 1)->first()?->getThumbnail();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user