fixed brand for https://guangdagit.com/beike/beikeshop/issues/107
This commit is contained in:
parent
35c464f47e
commit
36208c0c35
|
|
@ -18,7 +18,7 @@ class Brand extends Base
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
protected $fillable = ['name', 'country_id', 'first', 'logo', 'code', 'sort_order', 'status'];
|
protected $fillable = ['name', 'first', 'logo', 'sort_order', 'status'];
|
||||||
|
|
||||||
public function products() :HasMany
|
public function products() :HasMany
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,14 @@ class BrandRepo
|
||||||
*/
|
*/
|
||||||
public static function create($data)
|
public static function create($data)
|
||||||
{
|
{
|
||||||
return Brand::query()->create($data);
|
$brandData = [
|
||||||
|
'name' => $data['name'] ?? '',
|
||||||
|
'first' => $data['first'] ?? '',
|
||||||
|
'logo' => $data['logo'] ?? '',
|
||||||
|
'sort_order' => (int)($data['sort_order'] ?? 0),
|
||||||
|
'status' => (bool)($data['status'] ?? 1),
|
||||||
|
];
|
||||||
|
return Brand::query()->create($brandData);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -48,7 +55,15 @@ class BrandRepo
|
||||||
if (!$brand) {
|
if (!$brand) {
|
||||||
throw new Exception("品牌id $brand 不存在");
|
throw new Exception("品牌id $brand 不存在");
|
||||||
}
|
}
|
||||||
$brand->update($data);
|
|
||||||
|
$brandData = [
|
||||||
|
'name' => $data['name'] ?? '',
|
||||||
|
'first' => $data['first'] ?? '',
|
||||||
|
'logo' => $data['logo'] ?? '',
|
||||||
|
'sort_order' => (int)($data['sort_order'] ?? 0),
|
||||||
|
'status' => (bool)($data['status'] ?? 1),
|
||||||
|
];
|
||||||
|
$brand->update($brandData);
|
||||||
return $brand;
|
return $brand;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue