feat: add Post model, migration, and factory
Adds the Post model belonging to Site (required, cascade-deletes with the site) and SocialAccount (nullable, nulled out on account delete). Foundation for the Scheduled Posts feature; later tasks build the Livewire CRUD UI and API on top of this model. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
4293475ce1
commit
f746c5d6a0
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class Post extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
public const TYPES = [
|
||||
'twitter', 'instagram', 'facebook', 'reddit',
|
||||
'tiktok', 'linkedin', 'youtube', 'blog', 'other',
|
||||
];
|
||||
|
||||
public const STATUSES = ['draft', 'scheduled', 'published', 'failed'];
|
||||
|
||||
protected $fillable = [
|
||||
'site_id',
|
||||
'social_account_id',
|
||||
'type',
|
||||
'title',
|
||||
'body',
|
||||
'status',
|
||||
'scheduled_at',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'scheduled_at' => 'datetime',
|
||||
];
|
||||
|
||||
public function site(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Site::class);
|
||||
}
|
||||
|
||||
public function socialAccount(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(SocialAccount::class);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user