admin menu filter and seller

This commit is contained in:
merdan 2022-09-25 21:06:53 +05:00
parent de321d9b5a
commit 0a92c9cf6d
3 changed files with 12 additions and 9 deletions

View File

@ -56,8 +56,15 @@ class Vendors extends V1Controller
}
public function menus(MenuRepository $repository){
$menus = $repository->where('status',1)->with(['categories','brands'])->orderBy('position','asc')->get();
return Menu::collection($menus);
$vendors = $this->vendorRepository->select('marketplace_sellers.id','url','shop_title')
->where('is_approved',true)
->with(['menus' => function($query){
$query->where('status',1)
->with(['categories','brands'])
->orderBy('position','asc')
}])
return Vendor::collection($vendors)
}
public function index()

View File

@ -17,6 +17,7 @@ class Menu extends JsonResource
return [
'id' => $this->id,
'name' => $this->name,
'filter' => $this->filter,
'description' => $this->description,
'categories' => Category::collection($this->categories),
'brands' => Brands::collection($this->brands)

View File

@ -4,6 +4,7 @@ namespace Sarga\API\Http\Resources\Core;
use Illuminate\Http\Resources\Json\JsonResource;
use Sarga\API\Http\Resources\Catalog\Category;
use Sarga\API\Http\Resources\Catalog\Menu;
class Vendor extends JsonResource
{
@ -17,15 +18,9 @@ class Vendor extends JsonResource
{
return [
'id' => $this->id,
'url' => $this->url,
'shop_title' => $this->shop_title,
'logo' => $this->logo_url,
'banner' => $this->banner_url,
'brand_id' => $this->brand_attribute_id,
$this->mergeWhen(!empty($this->main_categories) && $this->main_categories->count(),[
'categories' => Category::collection($this->main_categories)
])
'menus' => Menu::collection($this->menus)
];
}
}