changes
This commit is contained in:
@ -0,0 +1,111 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Product\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Modules\Product\Models\FabricCategory;
|
||||
use Modules\Product\Repositories\FabricCategoryRepository;
|
||||
|
||||
class FabricCategoryController extends Controller
|
||||
{
|
||||
private $fabricCategoryRepository;
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function __construct(
|
||||
FabricCategoryRepository $fabricCategoryRepository)
|
||||
{
|
||||
$this->fabricCategoryRepository = $fabricCategoryRepository;
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$data['title'] = 'Fabric Categories List';
|
||||
$data['fabric_categories'] = $this->fabricCategoryRepository->findAll();
|
||||
|
||||
return view('product::fabric_category.index', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$data['title'] = 'Create Fabric Categories';
|
||||
$data['status'] = FabricCategory::STATUS;
|
||||
|
||||
return view('product::fabric_category.create', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
|
||||
$request->request->add(['slug' => slugify($request->title)]);
|
||||
$inputData = $request->all();
|
||||
$this->fabricCategoryRepository->create($inputData);
|
||||
toastr()->success('Category Created Succesfully');
|
||||
|
||||
return redirect()->route('fabricCategory.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
$data['title'] = 'Show Fabric Category';
|
||||
$data['status'] = FabricCategory::STATUS;
|
||||
$data['fabric_category'] = $this->fabricCategoryRepository->getFabricCategoryById($id);
|
||||
|
||||
return view('product::fabric_category.show', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$data['title'] = 'Edit Fabric Category';
|
||||
$data['status'] = FabricCategory::STATUS;
|
||||
$data['fabric_category'] = $this->fabricCategoryRepository->getFabricCategoryById($id);
|
||||
|
||||
return view('product::fabric_category.edit', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, $id): RedirectResponse
|
||||
{
|
||||
$inputData = $request->except(['_method', '_token']);
|
||||
$this->fabricCategoryRepository->update($id, $inputData);
|
||||
|
||||
return redirect()->route('fabricCategory.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
try {
|
||||
$FabricCategoryModel = $this->fabricCategoryRepository->getFabricCategoryById($id);
|
||||
$FabricCategoryModel->delete();
|
||||
|
||||
toastr()->success('Fabric Category Delete Succesfully');
|
||||
} catch (\Throwable $th) {
|
||||
toastr()->error($th->getMessage());
|
||||
}
|
||||
|
||||
return response()->json(['status' => true, 'message' => 'Fabric Category Delete Succesfully']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -5,8 +5,10 @@ namespace Modules\Product\Http\Controllers;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Modules\Product\Models\FabricCategory;
|
||||
use Modules\Product\Models\Product;
|
||||
use Modules\Product\Repositories\CategoryRepository;
|
||||
use Modules\Product\Repositories\FabricCategoryRepository;
|
||||
use Modules\Product\Repositories\ProductInterface;
|
||||
use Modules\Product\Repositories\ProductRepository;
|
||||
use Modules\Product\Repositories\SubCategoryRepository;
|
||||
@ -19,6 +21,7 @@ class ProductController extends Controller
|
||||
private $productRepository;
|
||||
private $categoryRepository;
|
||||
private $subCategoryRepository;
|
||||
private $fabricCategoryRepository;
|
||||
private $warehouseRepository;
|
||||
private $supplierRepository;
|
||||
|
||||
@ -29,11 +32,13 @@ class ProductController extends Controller
|
||||
CategoryRepository $categoryRepository,
|
||||
SubCategoryRepository $subCategoryRepository,
|
||||
SupplierRepository $supplierRepository,
|
||||
FabricCategoryRepository $fabricCategoryRepository,
|
||||
WarehouseRepository $warehouseRepository)
|
||||
{
|
||||
$this->productRepository = $productRepository;
|
||||
$this->categoryRepository = $categoryRepository;
|
||||
$this->subCategoryRepository = $subCategoryRepository;
|
||||
$this->fabricCategoryRepository = $fabricCategoryRepository;
|
||||
$this->supplierRepository = $supplierRepository;
|
||||
$this->warehouseRepository = $warehouseRepository;
|
||||
}
|
||||
@ -52,6 +57,7 @@ class ProductController extends Controller
|
||||
{
|
||||
$data['title'] = 'Create Product';
|
||||
$data['category'] = $this->categoryRepository->pluck();
|
||||
$data['fabricCategory'] = $this->fabricCategoryRepository->pluck();
|
||||
$data['subCategory'] = $this->subCategoryRepository->pluck();
|
||||
$data['supplier'] = $this->supplierRepository->pluck();
|
||||
$data['warehouse'] = $this->warehouseRepository->pluck();
|
||||
@ -92,6 +98,7 @@ class ProductController extends Controller
|
||||
$data['title'] = 'Show Product';
|
||||
$data['category'] = $this->categoryRepository->pluck();
|
||||
$data['subCategory'] = $this->subCategoryRepository->pluck();
|
||||
$data['fabricCategory'] = $this->fabricCategoryRepository->pluck();
|
||||
$data['supplier'] = $this->supplierRepository->pluck();
|
||||
$data['warehouse'] = $this->warehouseRepository->pluck();
|
||||
$data['product'] = $this->productRepository->getProductById($id);
|
||||
@ -127,4 +134,18 @@ class ProductController extends Controller
|
||||
|
||||
return response()->json(['status' => true, 'message' => 'Product Delete Succesfully']);
|
||||
}
|
||||
|
||||
public function getProductDetail(Request $request)
|
||||
{
|
||||
try {
|
||||
$productModel = $this->productRepository->getProductById($request->id);
|
||||
} catch (\Throwable $th) {
|
||||
toastr()->error($th->getMessage());
|
||||
|
||||
}
|
||||
return response()->json([
|
||||
'status' => true,
|
||||
'data' => $productModel,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user