36 lines
1.1 KiB
PHP
36 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace Modules\Mall\Http\Resources\Api\Shop;
|
|
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class ShopResource extends JsonResource
|
|
{
|
|
|
|
public function toArray($request): array
|
|
{
|
|
return [
|
|
'shop_id' => $this->id,
|
|
'name' => $this->name,
|
|
'is_self' => (bool) $this->is_self,
|
|
'description' => $this->description,
|
|
'user' => [
|
|
'user_id' => $this->user->id,
|
|
'nickname' => $this->user->info->nickname,
|
|
'avatar' => $this->user->info->avatar ?? '',
|
|
],
|
|
'mobile' => $this->mobile,
|
|
'cover' => $this->cover_url,
|
|
'goodsCount' => $this->goods()->count(),
|
|
'region' => [
|
|
'province' => $this->province->name,
|
|
'city' => $this->city->name,
|
|
'district' => $this->district->name,
|
|
'address' => $this->address,
|
|
],
|
|
'created_at' => (string) $this->created_at,
|
|
];
|
|
}
|
|
|
|
}
|