- Create post_social_account pivot table for many-to-many relationship - Add migration to migrate existing social_account_id to pivot table - Remove social_account_id column from posts table - Update Post model with socialAccounts() BelongsToMany relationship - Update Posts Livewire component to use array of selectedAccountIds - Update Posts view with checkboxes for selecting multiple accounts - Update PublishPostJob to iterate through all social accounts of matching type - Update Publisher interface to accept optional SocialAccount parameter - Update all Publishers (WordPress, Reddit, Twitter, LinkedIn) to support cross-posting - Display multiple social accounts as badges in posts table Now a single post can be published to multiple social accounts of the same type. For example: a Twitter post can be published to multiple Twitter accounts. Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
48 lines
1.0 KiB
PHP
48 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\BelongsToMany;
|
|
|
|
class Post extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
public const TYPES = [
|
|
'twitter', 'instagram', 'facebook', 'reddit',
|
|
'tiktok', 'linkedin', 'youtube', 'blog', 'other',
|
|
];
|
|
|
|
public const STATUSES = ['draft', 'scheduled', 'publishing', 'published', 'failed'];
|
|
|
|
protected $fillable = [
|
|
'site_id',
|
|
'type',
|
|
'title',
|
|
'body',
|
|
'target',
|
|
'image_url',
|
|
'status',
|
|
'scheduled_at',
|
|
'published_url',
|
|
'publish_error',
|
|
];
|
|
|
|
protected $casts = [
|
|
'scheduled_at' => 'datetime',
|
|
];
|
|
|
|
public function site(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Site::class);
|
|
}
|
|
|
|
public function socialAccounts(): BelongsToMany
|
|
{
|
|
return $this->belongsToMany(SocialAccount::class, 'post_social_account');
|
|
}
|
|
}
|