Deploy Ladill Woo Manager / deploy (push) Successful in 55s
Sync catalog via plugin webhooks and REST proxy, with list/create/edit UI and updated logo from monolith assets. Co-authored-by: Cursor <cursoragent@cursor.com>
51 lines
1.2 KiB
PHP
51 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
|
|
class WooCategory extends Model
|
|
{
|
|
protected $fillable = [
|
|
'woo_store_id',
|
|
'external_id',
|
|
'parent_external_id',
|
|
'name',
|
|
'slug',
|
|
'description',
|
|
'product_count',
|
|
'wc_updated_at',
|
|
'metadata',
|
|
];
|
|
|
|
protected $casts = [
|
|
'wc_updated_at' => 'datetime',
|
|
'metadata' => 'array',
|
|
];
|
|
|
|
public function store(): BelongsTo
|
|
{
|
|
return $this->belongsTo(WooStore::class, 'woo_store_id');
|
|
}
|
|
|
|
public function children(): HasMany
|
|
{
|
|
return $this->hasMany(self::class, 'parent_external_id', 'external_id')
|
|
->whereColumn('woo_store_id', 'woo_categories.woo_store_id');
|
|
}
|
|
|
|
public function parentLabel(): ?string
|
|
{
|
|
if (! $this->parent_external_id) {
|
|
return null;
|
|
}
|
|
|
|
return self::query()
|
|
->where('woo_store_id', $this->woo_store_id)
|
|
->where('external_id', $this->parent_external_id)
|
|
->value('name');
|
|
}
|
|
}
|