Initial Commit
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user