57 lines
1.4 KiB
PHP
57 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
|
|
class MakerWorldCollection extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $table = 'makerworld_collections';
|
|
|
|
protected $fillable = [
|
|
'makerworld_collection_id',
|
|
'name',
|
|
'slug',
|
|
'description',
|
|
'cover_url',
|
|
'user_handle',
|
|
'source_url',
|
|
'is_active_sync',
|
|
'sync_interval_minutes',
|
|
'items_count',
|
|
'last_synced_at',
|
|
'last_sync_status',
|
|
'last_sync_message',
|
|
'raw_metadata',
|
|
];
|
|
|
|
protected $casts = [
|
|
'is_active_sync' => 'boolean',
|
|
'sync_interval_minutes' => 'integer',
|
|
'items_count' => 'integer',
|
|
'last_synced_at' => 'datetime',
|
|
'raw_metadata' => 'array',
|
|
];
|
|
|
|
public function products(): HasMany
|
|
{
|
|
return $this->hasMany(Product::class, 'makerworld_collection_id');
|
|
}
|
|
|
|
public function draftProducts(): HasMany
|
|
{
|
|
return $this->hasMany(Product::class, 'makerworld_collection_id')
|
|
->where('status', 'draft');
|
|
}
|
|
|
|
public function publishedProducts(): HasMany
|
|
{
|
|
return $this->hasMany(Product::class, 'makerworld_collection_id')
|
|
->where('status', 'published');
|
|
}
|
|
}
|