first commit

This commit is contained in:
Sampanna Rimal
2024-08-27 17:48:06 +05:45
commit 53c0140f58
10839 changed files with 1125847 additions and 0 deletions

View File

@ -0,0 +1,105 @@
<?php
namespace Modules\Product\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Modules\Product\Models\Category;
use Modules\Product\Repositories\CategoryRepository;
class CategoryController extends Controller
{
private $categoryRepository;
/**
* Display a listing of the resource.
*/
public function __construct(
CategoryRepository $categoryRepository) {
$this->categoryRepository = $categoryRepository;
}
public function index()
{
$data['title'] = 'Categories List';
$data['categories'] = $this->categoryRepository->findAll();
return view('product::category.index', $data);
}
/**
* Show the form for creating a new resource.
*/
public function create()
{
$data['title'] = 'Create Category';
$data['status'] = Category::STATUS;
return view('product::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->categoryRepository->create($inputData);
toastr()->success('Category Created Succesfully');
return redirect()->route('category.index');
}
/**
* Show the specified resource.
*/
public function show($id)
{
$data['title'] = 'Show Category';
$data['status'] = Category::STATUS;
$data['category'] = $this->categoryRepository->getCategoryById($id);
return view('product::category.show', $data);
}
/**
* Show the form for editing the specified resource.
*/
public function edit($id)
{
$data['title'] = 'Edit Category';
$data['status'] = Category::STATUS;
$data['category'] = $this->categoryRepository->getCategoryById($id);
return view('product::category.edit', $data);
}
/**
* Update the specified resource in storage.
*/
public function update(Request $request, $id): RedirectResponse
{
$inputData = $request->except(['_method', '_token']);
$this->categoryRepository->update($id, $inputData);
return redirect()->route('category.index');
}
/**
* Remove the specified resource from storage.
*/
public function destroy($id)
{
try {
$CategoryModel = $this->categoryRepository->getCategoryById($id);
$CategoryModel->delete();
toastr()->success('Product Delete Succesfully');
} catch (\Throwable $th) {
toastr()->error($th->getMessage());
}
return response()->json(['status' => true, 'message' => 'Category Delete Succesfully']);
}
}

View File

@ -0,0 +1,130 @@
<?php
namespace Modules\Product\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Modules\Product\Models\Product;
use Modules\Product\Repositories\CategoryRepository;
use Modules\Product\Repositories\ProductInterface;
use Modules\Product\Repositories\ProductRepository;
use Modules\Product\Repositories\SubCategoryRepository;
use Modules\Product\Repositories\WarehouseRepository;
use Modules\Supplier\Models\Supplier;
use Modules\Supplier\Repositories\SupplierRepository;
class ProductController extends Controller
{
private $productRepository;
private $categoryRepository;
private $subCategoryRepository;
private $warehouseRepository;
private $supplierRepository;
/**
* Display a listing of the resource.
*/
public function __construct(ProductRepository $productRepository,
CategoryRepository $categoryRepository,
SubCategoryRepository $subCategoryRepository,
SupplierRepository $supplierRepository,
WarehouseRepository $warehouseRepository)
{
$this->productRepository = $productRepository;
$this->categoryRepository = $categoryRepository;
$this->subCategoryRepository = $subCategoryRepository;
$this->supplierRepository = $supplierRepository;
$this->warehouseRepository = $warehouseRepository;
}
public function index()
{
$data['title'] = "Product Lists";
$data['products'] = $this->productRepository->findAll();
return view('product::product.index', $data);
}
/**
* Show the form for creating a new resource.
*/
public function create()
{
$data['title'] = 'Create Product';
$data['category'] = $this->categoryRepository->pluck();
$data['subCategory'] = $this->subCategoryRepository->pluck();
$data['supplier'] = $this->supplierRepository->pluck();
$data['warehouse'] = $this->warehouseRepository->pluck();
$data['status'] = Product::STATUS;
return view('product::product.create', $data);
}
/**
* Store a newly created resource in storage.
*/
public function store(Request $request): RedirectResponse
{
$inputData = $request->all();
$this->productRepository->create($inputData);
toastr()->success('Product Created Succesfully');
return redirect()->route('product.index');
}
/**
* Show the specified resource.
*/
public function show($id)
{
$data['title'] = 'Show Product';
$data['product'] = $this->productRepository->getProductById($id);
$data['status'] = Product::STATUS;
return view('product::product.show', $data);
}
/**
* Show the form for editing the specified resource.
*/
public function edit($id)
{
$data['title'] = 'Show Product';
$data['category'] = $this->categoryRepository->pluck();
$data['subCategory'] = $this->subCategoryRepository->pluck();
$data['supplier'] = $this->supplierRepository->pluck();
$data['warehouse'] = $this->warehouseRepository->pluck();
$data['product'] = $this->productRepository->getProductById($id);
$data['status'] = Product::STATUS;
return view('product::product.edit', $data);
}
/**
* Update the specified resource in storage.
*/
public function update(Request $request, $id): RedirectResponse
{
$inputData = $request->except(['_method', '_token']);
$this->productRepository->update($id, $inputData);
return redirect()->route('product.index');
}
/**
* Remove the specified resource from storage.
*/
public function destroy($id)
{
try {
$ProductModel = $this->productRepository->getProductById($id);
$ProductModel->delete();
toastr()->success('Product Delete Succesfully');
} catch (\Throwable $th) {
toastr()->error($th->getMessage());
}
return response()->json(['status' => true, 'message' => 'Product Delete Succesfully']);
}
}

View File

@ -0,0 +1,124 @@
<?php
namespace Modules\Product\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Modules\Product\Models\SubCategory;
use Modules\Product\Repositories\CategoryRepository;
use Modules\Product\Repositories\SubCategoryRepository;
class SubCategoryController extends Controller
{
private $subCategoryRepository;
private $categoryRepository;
/**
* Display a listing of the resource.
*/
public function __construct(
SubCategoryRepository $subCategoryRepository,
CategoryRepository $categoryRepository)
{
$this->subCategoryRepository = $subCategoryRepository;
$this->categoryRepository = $categoryRepository;
}
public function index()
{
$data['title'] = 'Sub Categories List';
$data['sub_categories'] = $this->subCategoryRepository->findAll();
return view('product::sub_category.index', $data);
}
/**
* Show the form for creating a new resource.
*/
public function create()
{
$data['title'] = 'Create Sub Categories';
$data['status'] = SubCategory::STATUS;
$data['category'] = $this->categoryRepository->pluck();
return view('product::sub_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->subCategoryRepository->create($inputData);
toastr()->success('Category Created Succesfully');
return redirect()->route('subCategory.index');
}
/**
* Show the specified resource.
*/
public function show($id)
{
$data['title'] = 'Show Category';
$data['status'] = SubCategory::STATUS;
$data['sub_category'] = $this->subCategoryRepository->getSubCategoryById($id);
return view('product::sub_category.show', $data);
}
/**
* Show the form for editing the specified resource.
*/
public function edit($id)
{
$data['title'] = 'Edit Category';
$data['status'] = SubCategory::STATUS;
$data['category'] = $this->categoryRepository->pluck();
$data['sub_category'] = $this->subCategoryRepository->getSubCategoryById($id);
return view('product::sub_category.edit', $data);
}
/**
* Update the specified resource in storage.
*/
public function update(Request $request, $id): RedirectResponse
{
$inputData = $request->except(['_method', '_token']);
$this->subCategoryRepository->update($id, $inputData);
return redirect()->route('subCategory.index');
}
/**
* Remove the specified resource from storage.
*/
public function destroy($id)
{
try {
$SubCategoryModel = $this->subCategoryRepository->getSubCategoryById($id);
$SubCategoryModel->delete();
toastr()->success('Sub Category Delete Succesfully');
} catch (\Throwable $th) {
toastr()->error($th->getMessage());
}
return response()->json(['status' => true, 'message' => 'Sub Category Delete Succesfully']);
}
public function getSubCategories(Request $request)
{
$category_id = $request->category_id;
$subcategories = SubCategory::where('category_id',$category_id)->get();
return response()->json(['status'=>200, 'message'=>$subcategories]);
}
}

View File

@ -0,0 +1,103 @@
<?php
namespace Modules\Product\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Modules\Product\Models\Warehouse;
use Modules\Product\Repositories\WarehouseRepository;
class WarehouseController extends Controller
{
private $warehouseRepository;
/**
* Display a listing of the resource.
*/
public function __construct(WarehouseRepository $warehouseRepository)
{
$this->warehouseRepository = $warehouseRepository;
}
public function index()
{
$data['title'] = 'WareHouse List';
$data['warehouses'] = $this->warehouseRepository->findAll();
return view('product::warehouse.index', $data);
}
/**
* Show the form for creating a new resource.
*/
public function create()
{
$data['title'] = 'Create Warehouse';
$data['status'] = Warehouse::STATUS;
return view('product::warehouse.create', $data);
}
/**
* Store a newly created resource in storage.
*/
public function store(Request $request): RedirectResponse
{
$inputData = $request->all();
$this->warehouseRepository->create($inputData);
toastr()->success('Warehouse Created Succesfully');
return redirect()->route('warehouse.index');
}
/**
* Show the specified resource.
*/
public function show($id)
{
$data['title'] = 'Show Warehouse';
$data['warehouse'] = $this->warehouseRepository->getWarehouseById($id);
$data['status'] = Warehouse::STATUS;
return view('product::warehouse.show', $data);
}
/**
* Show the form for editing the specified resource.
*/
public function edit($id)
{
$data['title'] = 'Edit Category';
$data['warehouse'] = $this->warehouseRepository->getWarehouseById($id);
$data['status'] = Warehouse::STATUS;
return view('product::warehouse.edit', $data);
}
/**
* Update the specified resource in storage.
*/
public function update(Request $request, $id): RedirectResponse
{
$inputData = $request->except(['_method', '_token']);
$this->warehouseRepository->update($id, $inputData);
return redirect()->route('warehouse.index');
}
/**
* Remove the specified resource from storage.
*/
public function destroy($id)
{
try {
$WarehouseModel = $this->warehouseRepository->getWarehouseById($id);
$WarehouseModel->delete();
toastr()->success('Warehouse Delete Succesfully');
} catch (\Throwable $th) {
toastr()->error($th->getMessage());
}
return response()->json(['status' => true, 'message' => 'Warehouse Delete Succesfully']);
}
}