New-OMIS/Modules/Admin/app/Http/Controllers/PromotionDemotionController.php

88 lines
2.5 KiB
PHP
Raw Normal View History

2024-04-14 12:44:29 +00:00
<?php
namespace Modules\Admin\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Modules\Admin\Repositories\PromotionDemotionRepository;
class PromotionDemotionController extends Controller
{
private $promotionDemotionRepository;
public function __construct(PromotionDemotionRepository $promotionDemotionRepository)
{
$this->promotionDemotionRepository = $promotionDemotionRepository;
}
/**
* Display a listing of the resource.
*/
public function index()
{
$data['title'] = "Promotion/ Demotion Lists";
$data['promotionDemotionLists'] = $this->promotionDemotionRepository->findAll();
return view('admin::promotiondemotions.index', $data);
}
/**
* Show the form for creating a new resource.
*/
public function create()
{
$data['editable'] = false;
$data['title'] = "Create Promotion/ Demotion";
return view('admin::promotiondemotions.create', $data);
}
/**
* Store a newly created resource in storage.
*/
public function store(Request $request): RedirectResponse
{
$this->promotionDemotionRepository->create($request->all());
toastr()->success('Promotion/ Demotion Created Successfully');
return redirect()->route('promotionDemotion.index');
}
/**
* Show the specified resource.
*/
public function show($id)
{
return view('admin::promotiondemotions.show');
}
/**
* Show the form for editing the specified resource.
*/
public function edit($id)
{
$data['editable'] = false;
$data['title'] = "Edit Promotion/ Demotion";
$data['promotionDemotion'] = $this->promotionDemotionRepository->getPromotionDemotionById($id);
return view('admin::promotiondemotions.edit', $data);
}
/**
* Update the specified resource in storage.
*/
public function update(Request $request, $id): RedirectResponse
{
$this->promotionDemotionRepository->update($id, $request->all());
toastr()->success('Promotion/ Demotion Updated Successfully');
return redirect()->route('promotionDemotion.index');
}
/**
* Remove the specified resource from storage.
*/
public function destroy($id)
{
$this->promotionDemotionRepository->delete($id);
toastr()->success('Promotion/ Demotion Deleted Successfully');
return redirect()->route('promotionDemotion.index');
}
}