Allow artworks to have one primary category and extra secondaries.
Keep artwork_category as membership, store a deterministic primary_category_id, and let upload plus studio pick up to five additional same-type categories without changing canonical URLs.
This commit is contained in:
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class Upload extends Model
|
||||
{
|
||||
@@ -23,6 +24,7 @@ class Upload extends Model
|
||||
'title',
|
||||
'slug',
|
||||
'category_id',
|
||||
'secondary_category_ids',
|
||||
'description',
|
||||
'tags',
|
||||
'license',
|
||||
@@ -41,6 +43,7 @@ class Upload extends Model
|
||||
|
||||
protected $casts = [
|
||||
'tags' => 'array',
|
||||
'secondary_category_ids' => 'array',
|
||||
'nsfw' => 'boolean',
|
||||
'is_scanned' => 'boolean',
|
||||
'has_tags' => 'boolean',
|
||||
@@ -48,4 +51,14 @@ class Upload extends Model
|
||||
'expires_at' => 'datetime',
|
||||
'moderated_at' => 'datetime',
|
||||
];
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function category(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Category::class);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user