103 lines
2.8 KiB
PHP
103 lines
2.8 KiB
PHP
<?php
|
|
|
|
namespace Modules\Asset\Http\Controllers;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use Illuminate\Http\RedirectResponse;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Response;
|
|
use Modules\Admin\Services\AdminService;
|
|
use Modules\Asset\Repositories\AssetCategoryInterface;
|
|
use Modules\Employee\Repositories\EmployeeRepository;
|
|
|
|
class AssetCategoryController extends Controller
|
|
{
|
|
private $assetCategoryRepository;
|
|
private $adminService;
|
|
private $employeeRepository;
|
|
|
|
|
|
|
|
public function __construct(AssetCategoryInterface $assetCategoryRepository, AdminService $adminService, EmployeeRepository $employeeRepository)
|
|
{
|
|
$this->assetCategoryRepository = $assetCategoryRepository;
|
|
$this->adminService = $adminService;
|
|
$this->employeeRepository = $employeeRepository;
|
|
|
|
|
|
}
|
|
/**
|
|
* Display a listing of the resource.
|
|
*/
|
|
public function index()
|
|
{
|
|
$data['title'] = "Asset Category Lists";
|
|
$data['assetCategoryLists'] = $this->assetCategoryRepository->findAll();
|
|
return view('asset::assetcategories.index', $data);
|
|
}
|
|
|
|
/**
|
|
* Show the form for creating a new resource.
|
|
*/
|
|
public function create()
|
|
{
|
|
$data['title'] = "Create AssetCategory";
|
|
$data['editable'] = false;
|
|
$data['assetCategoryLists'] = $this->assetCategoryRepository->pluck();
|
|
$data['departmentList'] = $this->adminService->pluckDepartments();
|
|
$data['employeeList'] = $this->employeeRepository->pluck();
|
|
|
|
|
|
|
|
|
|
return view('asset::assetCategories.create', $data);
|
|
}
|
|
|
|
/**
|
|
* Store a newly created resource in storage.
|
|
*/
|
|
public function store(Request $request): RedirectResponse
|
|
{
|
|
$this->assetCategoryRepository->create($request->all());
|
|
toastr()->success('AssetCategory Created Successfully.');
|
|
return redirect()->route('assetCategory.index');
|
|
}
|
|
|
|
/**
|
|
* Show the specified resource.
|
|
*/
|
|
public function show($id)
|
|
{
|
|
return view('asset::assetcategories.show');
|
|
}
|
|
|
|
/**
|
|
* Show the form for editing the specified resource.
|
|
*/
|
|
public function edit($id)
|
|
{
|
|
$data['title'] = "Edit AssetCategory";
|
|
$data['editable'] = true;
|
|
$data['assetCategory'] = $this->assetCategoryRepository->getAssetCategoryById($id);
|
|
return view('asset::assetcategories.edit', $data);
|
|
}
|
|
|
|
/**
|
|
* Update the specified resource in storage.
|
|
*/
|
|
public function update(Request $request, $id): RedirectResponse
|
|
{
|
|
$this->assetCategoryRepository->update($id, $request->all());
|
|
toastr()->success('AssetCategory Updated Successfully.');
|
|
return redirect()->route('assetCategory.index');
|
|
}
|
|
|
|
/**
|
|
* Remove the specified resource from storage.
|
|
*/
|
|
public function destroy($id)
|
|
{
|
|
//
|
|
}
|
|
}
|