Posts get a nullable image_url. WordPressPublisher now downloads it and uploads it to WordPress's media endpoint before creating the post, setting it as featured_media — and rejects publishing (without touching status) if a blog post has no image set, mirroring the existing title requirement. Every other network treats it as optional. Not enforced at save time, same as title — you can still draft an incomplete WordPress post, it just can't be published until an image is set. Exposed through the UI form (with a thumbnail/""missing"" indicator in the table), the JSON API, and the Python CLI wrapper. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
48 lines
1013 B
PHP
48 lines
1013 B
PHP
<?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', 'publishing', 'published', 'failed'];
|
|
|
|
protected $fillable = [
|
|
'site_id',
|
|
'social_account_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 socialAccount(): BelongsTo
|
|
{
|
|
return $this->belongsTo(SocialAccount::class);
|
|
}
|
|
}
|