文件还在测试中

This commit is contained in:
2026-08-08 15:53:53 +08:00
parent 5f1e7adb64
commit 8101177cb5
241 changed files with 18074 additions and 22 deletions
+33
View File
@@ -0,0 +1,33 @@
<?php
namespace App\Models;
use Core\Model;
class Product extends Model
{
protected $table = 'products';
protected $orderBy = 'sort_order';
public function byCategory(int $catId): array
{
return $this->whereAll('category_id', $catId);
}
public function featured(int $limit = 6): array
{
return array_slice(array_filter($this->all(), fn($p) => ($p['status'] ?? 1) == 1), 0, $limit);
}
public function specsArray($p): array
{
$s = $p['specs'] ?? '';
if (is_array($s)) return $s;
$dec = json_decode((string)$s, true);
return is_array($dec) ? $dec : [];
}
public function galleryArray($p): array
{
$g = $p['gallery'] ?? '';
if (is_array($g)) return $g;
$dec = json_decode((string)$g, true);
return is_array($dec) ? $g : [];
}
}