Files
dredgy b2f2d8b104
linter / quality (push) Canceled after 0s
tests / ci (8.3) (push) Canceled after 0s
tests / ci (8.4) (push) Canceled after 0s
tests / ci (8.5) (push) Canceled after 0s
Initial Commit
2026-08-29 00:17:41 +10:00

45 lines
1.0 KiB
PHP

<?php
namespace App\Models;
use App\Observers\StoryObserver;
use Illuminate\Database\Eloquent\Attributes\ObservedBy;
use Illuminate\Database\Eloquent\Model;
#[ObservedBy(StoryObserver::class)]
class Story extends Model
{
protected $table = 'stories';
protected $keyType = 'string';
public $incrementing = false;
public $timestamps = false;
protected $fillable = [
'id', 'user_id', 'username', 'profile_pic_url', 'code',
'is_video', 'taken_at', 'expiring_at', 'image_url', 'video_url',
'accessibility_caption', 'muted', 'scraped_at',
'viewed_at',
];
protected $casts = [
'is_video' => 'boolean',
'taken_at' => 'integer',
'expiring_at' => 'integer',
'muted' => 'boolean',
'scraped_at' => 'datetime',
'viewed_at' => 'datetime',
];
public function scopeActive($query)
{
return $query->where('expiring_at', '>', now()->timestamp);
}
public function getIsUnreadAttribute(): bool
{
return $this->viewed_at === null;
}
}