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:
Doar Mihai
2026-07-18 17:07:48 +03:00
co-authored by Claude Sonnet 5
parent 4293475ce1
commit f746c5d6a0
4 changed files with 190 additions and 0 deletions
+43
View File
@@ -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);
}
}