<?php

namespace Modules\Mall\Http\Controllers\Api;

use App\Api\Controllers\Controller;
use Illuminate\Http\JsonResponse;
use Modules\Mall\Http\Resources\Api\Banner\BannerResource;
use Modules\Mall\Http\Resources\Api\Category\CategoryResource;
use Modules\Mall\Http\Resources\Api\Goods\BrandResource;
use Modules\Mall\Http\Resources\Api\Goods\TagResource;
use Modules\Mall\Http\Resources\Api\Shop\ExpressResource;
use Modules\Mall\Models\Shop;

class ShopExtendController extends Controller
{

    /**
     * Notes   : 店铺的分类列表
     * @Date   : 2021/5/13 10:28 上午
     * @Author : <Jason.C>
     * @param  \Modules\Mall\Models\Shop  $shop
     * @return \Illuminate\Http\JsonResponse
     */
    public function categories(Shop $shop): JsonResponse
    {
        $list = $shop->categories()->where('parent_id', 0)->get();

        return $this->success(CategoryResource::collection($list));
    }

    /**
     * Notes   : 店铺标签
     * @Date   : 2021/5/13 11:35 上午
     * @Author : <Jason.C>
     * @param  \Modules\Mall\Models\Shop  $shop
     * @return \Illuminate\Http\JsonResponse
     */
    public function tags(Shop $shop): JsonResponse
    {
        $list = $shop->tags()->get();

        return $this->success(TagResource::collection($list));
    }

    /**
     * Notes   : 店铺品牌
     * @Date   : 2021/5/13 11:35 上午
     * @Author : <Jason.C>
     * @param  \Modules\Mall\Models\Shop  $shop
     * @return \Illuminate\Http\JsonResponse
     */
    public function brands(Shop $shop): JsonResponse
    {
        $list = $shop->brands()->get();

        return $this->success(BrandResource::collection($list));
    }

    /**
     * Notes   : 支持的物流
     * @Date   : 2021/5/13 11:36 上午
     * @Author : <Jason.C>
     * @param  \Modules\Mall\Models\Shop  $shop
     * @return \Illuminate\Http\JsonResponse
     */
    public function expresses(Shop $shop): JsonResponse
    {
        $list = $shop->expresses()->get();

        return $this->success(ExpressResource::collection($list));
    }

    /**
     * Notes   : 轮播图
     * @Date   : 2021/5/13 11:36 上午
     * @Author : <Jason.C>
     * @param  \Modules\Mall\Models\Shop  $shop
     * @return \Illuminate\Http\JsonResponse
     */
    public function banners(Shop $shop): JsonResponse
    {
        $list = $shop->banners()->get();

        return $this->success(BannerResource::collection($list));
    }

}