One Hat Cyber Team
Your IP :
3.144.98.87
Server IP :
192.145.235.60
Server :
Linux ngx365.inmotionhosting.com 5.14.0-427.33.1.el9_4.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Aug 30 09:45:56 EDT 2024 x86_64
Server Software :
Apache
PHP Version :
8.2.27
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
home
/
centos12
/
www
/
centosuit
/
app
/
Http
/
Controllers
/
Edit File:
ProductCategoryController.php
<?php namespace App\Http\Controllers; use App\Helper\Reply; use App\Http\Requests\Product\StoreProductCategory; use App\Models\BaseModel; use App\Models\ProductCategory; class ProductCategoryController extends AccountBaseController { /** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create() { $this->categories = ProductCategory::all(); return view('products.category.create', $this->data); } /** * @param StoreProductCategory $request * @return array * @throws \Froiden\RestAPI\Exceptions\RelatedResourceNotFoundException */ public function store(StoreProductCategory $request) { $category = new ProductCategory(); $category->category_name = $request->category_name; $category->save(); $categories = ProductCategory::get(); $options = BaseModel::options($categories, $category, 'category_name'); return Reply::successWithData(__('messages.recordSaved'), ['data' => $options]); } /** * @param StoreProductCategory $request * @param int $id * @return array * @throws \Froiden\RestAPI\Exceptions\RelatedResourceNotFoundException */ public function update(StoreProductCategory $request, $id) { $category = ProductCategory::findOrFail($id); $category->category_name = strip_tags($request->category_name); $category->save(); $categories = ProductCategory::get(); $options = BaseModel::options($categories, null, 'category_name'); return Reply::successWithData(__('messages.updateSuccess'), ['data' => $options]); } /** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { ProductCategory::destroy($id); $categoryData = ProductCategory::all(); return Reply::successWithData(__('messages.deleteSuccess'), ['data' => $categoryData]); } }
Simpan