show brands

This commit is contained in:
Edward Yang 2022-08-04 15:12:48 +08:00
parent 9e77667360
commit c431ffbb83
2 changed files with 9 additions and 3 deletions

View File

@ -11,7 +11,9 @@
namespace Beike\Services; namespace Beike\Services;
use Beike\Repositories\BrandRepo;
use Beike\Repositories\ProductRepo; use Beike\Repositories\ProductRepo;
use Beike\Shop\Http\Resources\BrandDetail;
use Illuminate\Support\Str; use Illuminate\Support\Str;
class DesignService class DesignService
@ -79,10 +81,10 @@ class DesignService
*/ */
private static function handleBrand($content): array private static function handleBrand($content): array
{ {
$brands = $content['brands']; $brandIds = $content['brands'] ?? [];
$brands = BrandDetail::collection(BrandRepo::getListByIds($brandIds))->jsonSerialize();
$content['brands'] = $brands;
$content['brands'] = [];
$content['title'] = $content['title'][locale()]; $content['title'] = $content['title'][locale()];
return $content; return $content;
} }

View File

@ -15,6 +15,9 @@ use Illuminate\Http\Resources\Json\JsonResource;
class BrandDetail extends JsonResource class BrandDetail extends JsonResource
{ {
/**
* @throws \Exception
*/
public function toArray($request): array public function toArray($request): array
{ {
return [ return [
@ -22,6 +25,7 @@ class BrandDetail extends JsonResource
'name' => $this->name, 'name' => $this->name,
'logo' => image_resize($this->logo), 'logo' => image_resize($this->logo),
'sort_order' => $this->sort_order, 'sort_order' => $this->sort_order,
'url'=> shop_route('brands.show', $this->id),
'first' => $this->first, 'first' => $this->first,
]; ];
} }