restaurant changes
This commit is contained in:
0
Modules/Ingredient/app/Http/Controllers/.gitkeep
Normal file
0
Modules/Ingredient/app/Http/Controllers/.gitkeep
Normal file
@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Ingredient\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Modules\Ingredient\Models\IngredientCategory;
|
||||
use Modules\Ingredient\Repositories\IngredientCategoryRepository;
|
||||
|
||||
class IngredientCategoryController extends Controller
|
||||
{
|
||||
private $ingredientCategoryRepository;
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function __construct(
|
||||
IngredientCategoryRepository $ingredientCategoryRepository) {
|
||||
$this->ingredientCategoryRepository = $ingredientCategoryRepository;
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$data['title'] = 'Categories List';
|
||||
$data['categories'] = $this->ingredientCategoryRepository->findAll();
|
||||
return view('ingredient::ingredientCategory.index', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$data['title'] = 'Create IngredientCategory';
|
||||
$data['status'] = IngredientCategory::STATUS;
|
||||
|
||||
return view('ingredient::ingredientCategory.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->ingredientCategoryRepository->create($inputData);
|
||||
toastr()->success('IngredientCategory Created Succesfully');
|
||||
|
||||
return redirect()->route('ingredientCategory.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
$data['title'] = 'Show IngredientCategory';
|
||||
$data['status'] = IngredientCategory::STATUS;
|
||||
$data['category'] = $this->ingredientCategoryRepository->getIngredientCategoryById($id);
|
||||
|
||||
return view('ingredient::ingredientCategory.show', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$data['title'] = 'Edit IngredientCategory';
|
||||
$data['status'] = IngredientCategory::STATUS;
|
||||
|
||||
$data['category'] = $this->ingredientCategoryRepository->getIngredientCategoryById($id);
|
||||
|
||||
return view('ingredient::ingredientCategory.edit', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, $id): RedirectResponse
|
||||
{
|
||||
$inputData = $request->except(['_method', '_token']);
|
||||
$this->ingredientCategoryRepository->update($id, $inputData);
|
||||
|
||||
return redirect()->route('ingredientCategory.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
try {
|
||||
$IngredientCategoryModel = $this->ingredientCategoryRepository->getIngredientCategoryById($id);
|
||||
$IngredientCategoryModel->delete();
|
||||
|
||||
toastr()->success('Ingredient Delete Succesfully');
|
||||
} catch (\Throwable $th) {
|
||||
toastr()->error($th->getMessage());
|
||||
}
|
||||
|
||||
return response()->json(['status' => true, 'message' => 'IngredientCategory Delete Succesfully']);
|
||||
}
|
||||
}
|
152
Modules/Ingredient/app/Http/Controllers/IngredientController.php
Normal file
152
Modules/Ingredient/app/Http/Controllers/IngredientController.php
Normal file
@ -0,0 +1,152 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Ingredient\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Modules\Ingredient\Models\Unit;
|
||||
use Modules\Ingredient\Models\Ingredient;
|
||||
use Modules\Ingredient\Repositories\IngredientCategoryRepository;
|
||||
use Modules\Ingredient\Repositories\UnitRepository;
|
||||
use Modules\Ingredient\Repositories\IngredientInterface;
|
||||
use Modules\Ingredient\Repositories\IngredientRepository;
|
||||
use Modules\Supplier\Models\Supplier;
|
||||
use Modules\Supplier\Repositories\SupplierRepository;
|
||||
|
||||
class IngredientController extends Controller
|
||||
{
|
||||
private $ingredientRepository;
|
||||
private $ingredientCategoryRepository;
|
||||
private $unitRepository;
|
||||
private $supplierRepository;
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function __construct(IngredientRepository $ingredientRepository,
|
||||
IngredientCategoryRepository $ingredientCategoryRepository,
|
||||
SupplierRepository $supplierRepository,
|
||||
UnitRepository $unitRepository)
|
||||
{
|
||||
$this->ingredientRepository = $ingredientRepository;
|
||||
$this->ingredientCategoryRepository = $ingredientCategoryRepository;
|
||||
$this->unitRepository = $unitRepository;
|
||||
$this->supplierRepository = $supplierRepository;
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$data['title'] = "Ingredient Lists";
|
||||
$data['ingredients'] = $this->ingredientRepository->findAll();
|
||||
return view('ingredient::ingredient.index', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$data['title'] = 'Create Ingredient';
|
||||
$data['ingredientCategory'] = $this->ingredientCategoryRepository->pluck();
|
||||
$data['unit'] = $this->unitRepository->pluck();
|
||||
$data['supplier'] = $this->supplierRepository->pluck();
|
||||
$data['status'] = Ingredient::STATUS;
|
||||
|
||||
return view('ingredient::ingredient.create', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
$inputData = $request->all();
|
||||
$this->ingredientRepository->create($inputData);
|
||||
toastr()->success('Ingredient Created Succesfully');
|
||||
|
||||
return redirect()->route('ingredient.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
$data['title'] = 'Show Ingredient';
|
||||
$data['ingredient'] = $this->ingredientRepository->getIngredientById($id);
|
||||
$data['status'] = Ingredient::STATUS;
|
||||
|
||||
return view('ingredient::ingredient.show', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$data['title'] = 'Show Ingredient';
|
||||
$data['ingredientCategory'] = $this->ingredientCategoryRepository->pluck();
|
||||
$data['unit'] = $this->unitRepository->pluck();
|
||||
$data['supplier'] = $this->supplierRepository->pluck();
|
||||
$data['ingredient'] = $this->ingredientRepository->getIngredientById($id);
|
||||
$data['status'] = Ingredient::STATUS;
|
||||
|
||||
return view('ingredient::ingredient.edit', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, $id): RedirectResponse
|
||||
{
|
||||
$inputData = $request->except(['_method', '_token']);
|
||||
$this->ingredientRepository->update($id, $inputData);
|
||||
|
||||
return redirect()->route('ingredient.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
try {
|
||||
$IngredientModel = $this->ingredientRepository->getIngredientById($id);
|
||||
$IngredientModel->delete();
|
||||
|
||||
toastr()->success('Ingredient Delete Succesfully');
|
||||
} catch (\Throwable $th) {
|
||||
toastr()->error($th->getMessage());
|
||||
}
|
||||
|
||||
return response()->json(['status' => true, 'message' => 'Ingredient Delete Succesfully']);
|
||||
}
|
||||
|
||||
public function getIngredientDetail(Request $request)
|
||||
{
|
||||
try {
|
||||
$ingredientModel = $this->ingredientRepository->getIngredientById($request->id);
|
||||
} catch (\Throwable $th) {
|
||||
toastr()->error($th->getMessage());
|
||||
|
||||
}
|
||||
return response()->json([
|
||||
'status' => true,
|
||||
'data' => $ingredientModel,
|
||||
]);
|
||||
}
|
||||
|
||||
public function getIngredientsByCategory(Request $request)
|
||||
{
|
||||
$ingredientCategoryId = $request->ingredient_category_id;
|
||||
try {
|
||||
$ingredients = $this->ingredientRepository->getIngredientsByCategory($ingredientCategoryId);
|
||||
} catch (\Throwable $th) {
|
||||
toastr()->error($th->getMessage());
|
||||
}
|
||||
return response()->json(['ingredients' => $ingredients]);
|
||||
}
|
||||
|
||||
|
||||
}
|
111
Modules/Ingredient/app/Http/Controllers/UnitController.php
Normal file
111
Modules/Ingredient/app/Http/Controllers/UnitController.php
Normal file
@ -0,0 +1,111 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Ingredient\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Modules\Ingredient\Models\Unit;
|
||||
use Modules\Ingredient\Repositories\UnitRepository;
|
||||
|
||||
class UnitController extends Controller
|
||||
{
|
||||
private $unitRepository;
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function __construct(
|
||||
UnitRepository $unitRepository)
|
||||
{
|
||||
$this->unitRepository = $unitRepository;
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$data['title'] = 'Unit List';
|
||||
$data['units'] = $this->unitRepository->findAll();
|
||||
|
||||
return view('ingredient::unit.index', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$data['title'] = 'Create Unit';
|
||||
$data['status'] = Unit::STATUS;
|
||||
|
||||
return view('ingredient::unit.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->unitRepository->create($inputData);
|
||||
toastr()->success('Unit Created Succesfully');
|
||||
|
||||
return redirect()->route('unit.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
$data['title'] = 'Show Fabric Category';
|
||||
$data['status'] = Unit::STATUS;
|
||||
$data['unit'] = $this->unitRepository->getUnitById($id);
|
||||
|
||||
return view('ingredient::unit.show', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$data['title'] = 'Edit Fabric Category';
|
||||
$data['status'] = Unit::STATUS;
|
||||
$data['unit'] = $this->unitRepository->getUnitById($id);
|
||||
|
||||
return view('ingredient::unit.edit', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, $id): RedirectResponse
|
||||
{
|
||||
$inputData = $request->except(['_method', '_token']);
|
||||
$this->unitRepository->update($id, $inputData);
|
||||
|
||||
return redirect()->route('unit.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
try {
|
||||
$UnitModel = $this->unitRepository->getUnitById($id);
|
||||
$UnitModel->delete();
|
||||
|
||||
toastr()->success('Fabric Category Delete Succesfully');
|
||||
} catch (\Throwable $th) {
|
||||
toastr()->error($th->getMessage());
|
||||
}
|
||||
|
||||
return response()->json(['status' => true, 'message' => 'Fabric Category Delete Succesfully']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user