![]() 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\TaxRate; use Illuminate\Http\Response; use Illuminate\Support\Facades\Auth; use Modules\Connector\Transformers\CommonResource; /** * @group Tax management * @authenticated * * APIs for managing taxes */ class TaxController extends ApiController { /** * List taxes * * @response { "data": [ { "id": 1, "business_id": 1, "name": "VAT@10%", "amount": 10, "is_tax_group": 0, "created_by": 1, "woocommerce_tax_rate_id": null, "deleted_at": null, "created_at": "2018-01-04 02:40:07", "updated_at": "2018-01-04 02:40:07" }, { "id": 2, "business_id": 1, "name": "CGST@10%", "amount": 10, "is_tax_group": 0, "created_by": 1, "woocommerce_tax_rate_id": null, "deleted_at": null, "created_at": "2018-01-04 02:40:55", "updated_at": "2018-01-04 02:40:55" }, { "id": 3, "business_id": 1, "name": "SGST@8%", "amount": 8, "is_tax_group": 0, "created_by": 1, "woocommerce_tax_rate_id": null, "deleted_at": null, "created_at": "2018-01-04 02:41:13", "updated_at": "2018-01-04 02:41:13" }, { "id": 4, "business_id": 1, "name": "GST@18%", "amount": 18, "is_tax_group": 1, "created_by": 1, "woocommerce_tax_rate_id": null, "deleted_at": null, "created_at": "2018-01-04 02:42:19", "updated_at": "2018-01-04 02:42:19" } ] } */ public function index() { $user = Auth::user(); $business_id = $user->business_id; $taxes = TaxRate::where('business_id', $business_id) ->get(); return CommonResource::collection($taxes); } /** * Get the specified tax * * @urlParam tax required comma separated ids of required taxes Example: 1 * * @response { "data": [ { "id": 1, "business_id": 1, "name": "VAT@10%", "amount": 10, "is_tax_group": 0, "created_by": 1, "woocommerce_tax_rate_id": null, "deleted_at": null, "created_at": "2018-01-04 02:40:07", "updated_at": "2018-01-04 02:40:07" } ] } */ public function show($tax_ids) { $user = Auth::user(); $business_id = $user->business_id; $tax_ids = explode(',', $tax_ids); $taxes = TaxRate::where('business_id', $business_id) ->whereIn('id', $tax_ids) ->get(); return CommonResource::collection($taxes); } }