Aligns content module namespace with the standard module structure
convention (Core\Mod\{Name}) for consistency across the monorepo.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
68 lines
1.5 KiB
PHP
68 lines
1.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Core\Mod\Content\Models;
|
|
|
|
use Core\Mod\Tenant\Models\Workspace;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
|
|
class ContentAuthor extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected static function newFactory(): \Core\Mod\Content\Database\Factories\ContentAuthorFactory
|
|
{
|
|
return \Core\Mod\Content\Database\Factories\ContentAuthorFactory::new();
|
|
}
|
|
|
|
protected $fillable = [
|
|
'workspace_id',
|
|
'wp_id',
|
|
'name',
|
|
'slug',
|
|
'email',
|
|
'avatar_url',
|
|
'bio',
|
|
'social_links',
|
|
];
|
|
|
|
protected $casts = [
|
|
'social_links' => 'array',
|
|
];
|
|
|
|
/**
|
|
* Get the workspace this author belongs to.
|
|
*/
|
|
public function workspace(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Workspace::class);
|
|
}
|
|
|
|
/**
|
|
* Get all content items by this author.
|
|
*/
|
|
public function contentItems(): HasMany
|
|
{
|
|
return $this->hasMany(ContentItem::class, 'author_id');
|
|
}
|
|
|
|
/**
|
|
* Scope to filter by workspace.
|
|
*/
|
|
public function scopeForWorkspace($query, int $workspaceId)
|
|
{
|
|
return $query->where('workspace_id', $workspaceId);
|
|
}
|
|
|
|
/**
|
|
* Scope to find by WordPress ID.
|
|
*/
|
|
public function scopeByWpId($query, int $wpId)
|
|
{
|
|
return $query->where('wp_id', $wpId);
|
|
}
|
|
}
|