![]() Server : Apache/2.4.62 (Unix) OpenSSL/1.0.2k-fips System : Linux server1.richineiserver.com 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64 User : fdshops ( 1003) PHP Version : 8.2.21 Disable Function : NONE Directory : /home/fdshops/public_html/Modules/Connector/Http/Controllers/Api/ |
<?php namespace Modules\Connector\Http\Controllers\Api; use App\Brands; use Illuminate\Http\Response; use Illuminate\Support\Facades\Auth; use Modules\Connector\Transformers\CommonResource; /** * @group Brand management * @authenticated * * APIs for managing brands */ class BrandController extends ApiController { /** * List brands * * @response { "data": [ { "id": 1, "business_id": 1, "name": "Levis", "description": null, "created_by": 1, "deleted_at": null, "created_at": "2018-01-03 21:19:47", "updated_at": "2018-01-03 21:19:47" }, { "id": 2, "business_id": 1, "name": "Espirit", "description": null, "created_by": 1, "deleted_at": null, "created_at": "2018-01-03 21:19:58", "updated_at": "2018-01-03 21:19:58" } ] } */ public function index() { $user = Auth::user(); $business_id = $user->business_id; $brands = Brands::where('business_id', $business_id) ->get(); return CommonResource::collection($brands); } /** * Get the specified brand * * @urlParam brand required comma separated ids of the brands Example: 1 * @response { "data": [ { "id": 1, "business_id": 1, "name": "Levis", "description": null, "created_by": 1, "deleted_at": null, "created_at": "2018-01-03 21:19:47", "updated_at": "2018-01-03 21:19:47" } ] } */ public function show($brand_ids) { $user = Auth::user(); $business_id = $user->business_id; $brand_ids = explode(',', $brand_ids); $brands = Brands::where('business_id', $business_id) ->whereIn('id', $brand_ids) ->get(); return CommonResource::collection($brands); } }