<?php
//Obfuscated by YAK Pro - Php Obfuscator 2.0.13 at 2025-05-27 11:01:57
 namespace App\Http\Controllers\Admin; use App\Helpers\Helper; use App\Http\Controllers\Controller; use App\Product; use Illuminate\Http\Request; use Illuminate\Support\Arr; use App\ProductBestSeller; use App\Http\Resources\Admin\ProductBestSellerResource; use Validator; class ProductBestSellerController extends Controller { const ITEM_PER_PAGE = 100; public function index(Request $request) { goto QistD; QistD: $zpb2d = $request->all(); $ImHlC = Arr::get($zpb2d, "\154\x69\155\x69\x74", static::ITEM_PER_PAGE); $PLMJi = Arr::get($zpb2d, "\164\171\x70\145", 0); goto g_J7n; vZTdS: return ProductBestSellerResource::collection($qaDUi->paginate($ImHlC)); goto pJAfy; g_J7n: $knmpp = Arr::get($zpb2d, "\x63\141\164\145\147\157\162\x79\x5f\151\144", ''); $crjBp = Arr::get($zpb2d, "\155\x61\x6e\165\146\x61\x63\x74\165\162\145\162\x5f\x69\144", ''); $ncyai = Arr::get($zpb2d, "\x6b\145\x79\167\x6f\x72\x64", ''); goto qvlrW; xOuJ3: hlAr1: if (empty($crjBp)) { goto i0Z2Y; } $qaDUi->where("\155\x61\156\x75\146\x61\x63\x74\165\x72\x65\x72\137\151\x64", $crjBp); goto MKqu9; MKqu9: i0Z2Y: if (empty($ncyai)) { goto L9pAj; } $jWEkP = Product::where("\x6e\141\x6d\x65", "\114\111\x4b\105", "\x25" . $ncyai . "\x25")->orWhere("\151\x64", "\x4c\x49\113\x45", "\x25" . $ncyai . "\45")->pluck("\151\x64")->toArray(); goto akFjN; qvlrW: $qaDUi = ProductBestSeller::where("\x74\171\160\145", $PLMJi); if (empty($knmpp)) { goto hlAr1; } $qaDUi->where("\x63\141\x74\x65\x67\x6f\x72\171\x5f\151\144", $knmpp); goto xOuJ3; akFjN: $qaDUi->whereIn("\x70\x72\157\144\165\143\164\x5f\x69\144", $jWEkP); L9pAj: $qaDUi->orderBy("\160\157\163\151\x74\x69\x6f\x6e")->orderBy("\x69\x64"); goto vZTdS; pJAfy: } public function all(Request $request) { $zpb2d = $request->all(); $ImHlC = Arr::get($zpb2d, "\x6c\x69\x6d\x69\x74", static::ITEM_PER_PAGE); $qaDUi = ProductBestSeller::select("\x2a")->orderBy("\160\x6f\x73\151\x74\x69\157\x6e")->orderBy("\151\144"); return ProductBestSellerResource::collection($qaDUi->paginate($ImHlC)); } public function available(Request $request) { goto FM_WH; bNW1P: $qaDUi->where("\x69\x64", "\41\x3d", $uJxrT); xUqNr: $qaDUi->orderBy("\160\x6f\163\151\164\x69\157\156")->orderBy("\151\x64"); goto aPdMe; FM_WH: $uJxrT = Arr::get($request->all(), "\x69\x67\x6e\x6f\162\145\x49\144", ''); $qaDUi = ProductBestSeller::select("\x2a"); if (!($uJxrT != null && $uJxrT != '')) { goto xUqNr; } goto bNW1P; aPdMe: return ProductBestSellerResource::collection($qaDUi->get()); goto emiMf; emiMf: } public function show($kwsp6 = 0) { $LIJ4_ = ProductBestSeller::where("\151\x64", $kwsp6)->first(); if (isset($LIJ4_)) { goto xtr4n; } return response()->json(["\x65\162\x72\157\162\x73" => "\120\162\x6f\144\x75\143\164\40\x69\x73\x20\156\x6f\x74\x20\166\x61\154\151\144"], 403); xtr4n: return new ProductBestSellerResource($LIJ4_); } public function store(Request $request) { goto PBZ7z; raRqN: $ZAvpJ = []; foreach ($jWEkP as $VNJrB) { goto X03mu; hpn6G: v6Sgd: goto dcdDS; UTiau: if (!($Zqz7p <= 0)) { goto AjxI_; } $ZAvpJ[] = ["\x74\x79\160\x65" => $PLMJi, "\x63\141\164\x65\147\157\x72\x79\x5f\151\x64" => $T26RY->category_id, "\155\x61\156\x75\x66\x61\x63\164\165\x72\x65\162\x5f\151\x64" => $T26RY->manufacturer_id, "\160\162\x6f\x64\x75\143\x74\x5f\x69\144" => $T26RY->id, "\x70\x6f\x73\x69\x74\x69\157\x6e" => $DZlsL, "\x63\x72\x65\141\164\x65\x64\x5f\x61\x74" => date("\x59\55\155\x2d\x64\x20\110\72\151\72\163"), "\x75\x70\144\x61\x74\x65\x64\137\141\164" => date("\x59\55\x6d\55\x64\x20\x48\72\x69\x3a\163")]; AjxI_: goto hpn6G; X03mu: $DZlsL++; $Zqz7p = ProductBestSeller::where("\x74\171\160\x65", $PLMJi)->where("\x70\x72\157\144\165\x63\164\137\x69\144", $VNJrB)->count(); $T26RY = Product::where("\151\163\x5f\144\x65\154\145\x74\x65\144", false)->where("\x69\144", $VNJrB)->first(); goto UTiau; dcdDS: } ZPXgD: goto b4nfV; b4nfV: if (!(count($ZAvpJ) > 0)) { goto RiGHE; } ProductBestSeller::insert($ZAvpJ); RiGHE: goto vsgoy; jDt9Q: $jWEkP = Arr::get($params, "\x70\x72\157\144\165\143\164\163", []); $em0CA = ProductBestSeller::where("\x74\171\160\145", $PLMJi)->orderBy("\x69\x64", "\x44\105\x53\103")->first(); $DZlsL = isset($em0CA) ? $em0CA->position : 0; goto raRqN; P1if3: zYq8g: $params = $request->all(); $PLMJi = Arr::get($params, "\164\171\x70\x65", 0); goto jDt9Q; PBZ7z: $fMxOn = Validator::make($request->all(), ["\x74\171\160\145" => ["\x72\145\x71\165\151\162\x65\x64"], "\160\x72\157\144\165\143\164\163" => ["\162\145\x71\165\151\162\x65\144"]]); if (!$fMxOn->fails()) { goto zYq8g; } return response()->json(["\x65\162\162\157\x72\163" => $fMxOn->errors()], 403); goto P1if3; vsgoy: return response()->json(["\x73\164\x61\164\165\163" => "\x73\165\143\x63\x65\163\163"], 200); goto jDUOj; jDUOj: } public function update(Request $request, $kwsp6 = 0) { goto iI5qH; W3c2R: return response()->json(["\145\x72\162\x6f\162\x73" => "\120\162\157\144\165\143\164\x20\x69\163\x20\x6e\157\164\x20\x76\x61\x6c\151\x64"], 403); Df7Zq: $params = $request->all(); goto wn2ym; wn2ym: $fgf0L = $params["\163\x6c\165\x67"]; if (!($fgf0L == null || $fgf0L == '')) { goto Wwvxv; } $fgf0L = Helper::slug($params["\156\x61\155\145"]); goto pI4Dz; E8xBq: $DkUpf = $params["\160\x61\x72\x65\x6e\x74\137\x69\144"][array_key_last($params["\x70\141\x72\x65\156\x74\x5f\151\144"])]; CrS7q: $LIJ4_->update(["\x6e\141\155\145" => $params["\x6e\141\155\x65"], "\x73\x6c\165\x67" => Helper::slug($fgf0L), "\160\141\x72\x65\156\164\137\151\x64" => $DkUpf, "\x69\x6d\141\147\x65" => $params["\151\x6d\x61\147\145"], "\163\x75\142\137\x74\x69\x74\x6c\145" => $params["\163\165\142\x5f\164\151\164\154\x65"], "\x67\x72\157\x75\160" => $params["\x67\x72\x6f\165\x70"], "\144\145\x73\143\162\x69\160\164\151\x6f\156" => $params["\144\x65\x73\143\x72\x69\160\164\x69\x6f\x6e"], "\162\x61\156\x6b" => $params["\162\x61\x6e\x6b"] != null && $params["\162\141\156\x6b"] != '' ? $params["\x72\x61\156\x6b"] : null, "\x69\x73\137\164\157\160" => $params["\x69\163\x5f\x74\157\160"] === true ? 1 : 0, "\x69\x73\x5f\141\x63\164\151\166\141\164\145\x64" => $params["\x69\163\x5f\x61\143\x74\151\166\x61\x74\x65\144"] === true ? 1 : 0, "\x75\160\x64\x61\x74\145\x64\x5f\x61\164" => date("\x59\x2d\155\55\144\x20\110\72\x69\72\x73")]); goto pJ7V_; Up9lE: xA1ub: $LIJ4_ = ProductBestSeller::where("\151\x64", $kwsp6)->first(); if (isset($LIJ4_)) { goto Df7Zq; } goto W3c2R; iI5qH: $fMxOn = Validator::make($request->all(), ["\x6e\x61\155\145" => ["\162\145\x71\165\x69\162\x65\144"], "\151\163\137\x61\143\164\x69\166\x61\x74\x65\x64" => ["\x72\x65\161\x75\x69\162\145\144"]]); if (!$fMxOn->fails()) { goto xA1ub; } return response()->json(["\145\x72\x72\x6f\x72\x73" => $fMxOn->errors()], 403); goto Up9lE; pJ7V_: return response()->json(null, 204); goto wJ4Iq; pI4Dz: Wwvxv: $DkUpf = 0; if (!(is_array($params["\x70\x61\162\x65\156\x74\137\x69\144"]) && isset($params["\x70\x61\x72\x65\x6e\164\137\151\x64"][array_key_last($params["\160\141\x72\x65\x6e\x74\x5f\x69\144"])]))) { goto CrS7q; } goto E8xBq; wJ4Iq: } public function destroy($kwsp6 = 0) { $LIJ4_ = ProductBestSeller::where("\151\144", $kwsp6)->first(); if (isset($LIJ4_)) { goto xya_o; } response()->json(["\145\162\x72\157\162" => "\105\150\x68\150\41\40\103\141\x6e\x20\156\157\x74\40\144\145\x6c\145\164\x65\x20\x74\x68\x69\163\x20\120\162\x6f\144\x75\x63\164"], 403); xya_o: try { $LIJ4_->delete(); } catch (\Exception $baezg) { response()->json(["\x65\162\162\157\x72" => $baezg->getMessage()], 403); } return response()->json(null, 204); } public function destroyMultiple(Request $request) { goto EXd0g; Z1_w4: I2skA: $lEUHm = $request->get("\151\144\163", []); $SE6jG = ProductBestSeller::whereIn("\151\144", $lEUHm)->get(); goto eGT7u; ughg4: try { ProductBestSeller::whereIn("\x69\144", $lEUHm)->delete(); } catch (\Exception $baezg) { response()->json(["\x65\x72\x72\x6f\x72" => $baezg->getMessage()], 403); } return response()->json(null, 204); goto obi7M; eGT7u: if (!($SE6jG->count() <= 0)) { goto zkvi3; } response()->json(["\x65\x72\x72\157\162" => "\x50\x72\157\144\x75\143\x74\40\x69\x73\x20\x6e\157\164\x20\166\141\154\151\x64\x2e"], 403); zkvi3: goto ughg4; EXd0g: $fMxOn = Validator::make($request->all(), ["\151\144\x73" => "\162\145\x71\165\151\162\145\144"]); if (!$fMxOn->fails()) { goto I2skA; } return response()->json(["\x65\162\162\x6f\x72\x73" => $fMxOn->errors()], 403); goto Z1_w4; obi7M: } public function activateMultiple(Request $request) { goto OeDBz; uVoX_: if (!($SE6jG->count() <= 0)) { goto FoWZg; } response()->json(["\145\x72\x72\x6f\x72" => "\120\x72\157\x64\x75\143\164\40\151\163\x20\x6e\157\x74\x20\x76\x61\x6c\151\x64\x2e"], 403); FoWZg: goto T0ltr; OeDBz: $fMxOn = Validator::make($request->all(), ["\151\144\163" => "\x72\145\x71\165\151\x72\x65\x64"]); if (!$fMxOn->fails()) { goto AEKhe; } return response()->json(["\145\162\x72\157\162\x73" => $fMxOn->errors()], 403); goto C1McR; C1McR: AEKhe: $lEUHm = $request->get("\x69\x64\x73", []); $SE6jG = ProductBestSeller::whereIn("\x69\144", $lEUHm)->get(); goto uVoX_; T0ltr: try { ProductBestSeller::whereIn("\151\x64", $lEUHm)->update(["\151\163\x5f\141\x63\164\151\x76\141\x74\145\x64" => true]); } catch (\Exception $baezg) { response()->json(["\x65\x72\x72\x6f\162" => $baezg->getMessage()], 403); } return response()->json(null, 204); goto vgd44; vgd44: } public function deactivateMultiple(Request $request) { goto H0YXW; z1BBI: if (!($SE6jG->count() <= 0)) { goto VTKGR; } response()->json(["\x65\x72\162\157\162" => "\120\162\157\144\x75\x63\x74\40\x69\x73\x20\156\157\164\40\x76\x61\154\x69\144\56"], 403); VTKGR: goto MQZOT; H0YXW: $fMxOn = Validator::make($request->all(), ["\x69\x64\x73" => "\x72\x65\x71\x75\x69\x72\145\144"]); if (!$fMxOn->fails()) { goto Nt4jg; } return response()->json(["\x65\162\x72\157\x72\163" => $fMxOn->errors()], 403); goto KxWlf; MQZOT: try { ProductBestSeller::whereIn("\x69\144", $lEUHm)->update(["\x69\163\x5f\x61\143\x74\x69\x76\141\164\x65\x64" => false]); } catch (\Exception $baezg) { response()->json(["\145\162\162\x6f\x72" => $baezg->getMessage()], 403); } return response()->json(null, 204); goto Q8ghc; KxWlf: Nt4jg: $lEUHm = $request->get("\x69\144\163", []); $SE6jG = ProductBestSeller::whereIn("\x69\x64", $lEUHm)->get(); goto z1BBI; Q8ghc: } public function position(Request $request) { goto jTkrX; KxlVI: d8LrB: hQEED: return response()->json(null, 204); goto MqBEZ; jTkrX: if ($request->has("\x70\x6f\163\151\164\x69\x6f\156")) { goto leI1t; } return response()->json(["\x65\162\162\x6f\x72\x73" => "\104\141\164\x61\x20\151\x73\x20\151\156\166\141\154\151\144"], 403); leI1t: goto K3eAF; K3eAF: $P3gio = $request->position; if (!is_array($P3gio)) { goto hQEED; } foreach ($P3gio as $n06LY) { ProductBestSeller::where("\x69\144", $n06LY["\x69\x64"])->update(["\x70\157\163\x69\164\151\157\156" => $n06LY["\157\x72\x64\x65\x72"]]); Hj5CT: } goto KxlVI; MqBEZ: } }