52 lines
1.0 KiB
PHP
52 lines
1.0 KiB
PHP
<?php
|
|
|
|
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;
|
|
|
|
class Photo extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $table = 'photos';
|
|
protected $guarded = [];
|
|
protected $casts = [
|
|
'is_featured' => 'boolean',
|
|
'metadata' => 'array',
|
|
];
|
|
|
|
public function getImagePathAttribute(): ?string
|
|
{
|
|
return $this->file_path;
|
|
}
|
|
|
|
public function setImagePathAttribute(string $value): void
|
|
{
|
|
$this->attributes['file_path'] = $value;
|
|
}
|
|
|
|
public function event(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Event::class);
|
|
}
|
|
|
|
public function emotion(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Emotion::class);
|
|
}
|
|
|
|
public function task(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Task::class);
|
|
}
|
|
|
|
public function likes(): HasMany
|
|
{
|
|
return $this->hasMany(PhotoLike::class);
|
|
}
|
|
}
|
|
|