Add WooCommerce product and category management.
Deploy Ladill Woo Manager / deploy (push) Successful in 55s
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>
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
<?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');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user