99 lines
2.8 KiB
PHP
99 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\Asset\Repositories\AssetCategoryInterface;
|
||
|
use Modules\Asset\Repositories\AssetCategoryRepository;
|
||
|
use Modules\Asset\Repositories\AssetInterface;
|
||
|
use Modules\Asset\Repositories\AssetRepository;
|
||
|
use Modules\Employee\Repositories\EmployeeRepository;
|
||
|
|
||
|
class AssetController extends Controller
|
||
|
{
|
||
|
private $assetRepository;
|
||
|
private $assetCategoryRepository;
|
||
|
private $employeeRepository;
|
||
|
|
||
|
|
||
|
|
||
|
public function __construct(AssetInterface $assetRepository, AssetCategoryInterface $assetCategoryRepository, EmployeeRepository $employeeRepository)
|
||
|
{
|
||
|
$this->assetRepository = $assetRepository;
|
||
|
$this->assetCategoryRepository = $assetCategoryRepository;
|
||
|
$this->employeeRepository = $employeeRepository;
|
||
|
}
|
||
|
/**
|
||
|
* Display a listing of the resource.
|
||
|
*/
|
||
|
public function index()
|
||
|
{
|
||
|
$data['title'] = "Asset Lists";
|
||
|
$data['assetLists'] = $this->assetRepository->findAll();
|
||
|
return view('asset::assets.index', $data);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Show the form for creating a new resource.
|
||
|
*/
|
||
|
public function create()
|
||
|
{
|
||
|
$data['title'] = "Create Asset";
|
||
|
$data['editable'] = false;
|
||
|
$data['assetCategoryLists'] = $this->assetCategoryRepository->pluck();
|
||
|
$data['employeeList'] = $this->employeeRepository->pluck();
|
||
|
return view('asset::assets.create', $data);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Store a newly created resource in storage.
|
||
|
*/
|
||
|
public function store(Request $request): RedirectResponse
|
||
|
{
|
||
|
$this->assetRepository->create($request->all());
|
||
|
toastr()->success('Asset Created Successfully.');
|
||
|
return redirect()->route('asset.index');
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Show the specified resource.
|
||
|
*/
|
||
|
public function show($id)
|
||
|
{
|
||
|
return view('asset::assets.show');
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Show the form for editing the specified resource.
|
||
|
*/
|
||
|
public function edit($id)
|
||
|
{
|
||
|
$data['title'] = "Edit Asset";
|
||
|
$data['editable'] = true;
|
||
|
$data['assetCategoryLists'] = $this->assetCategoryRepository->pluck();
|
||
|
$data['asset'] = $this->assetRepository->getAssetById($id);
|
||
|
return view('asset::assets.edit', $data);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Update the specified resource in storage.
|
||
|
*/
|
||
|
public function update(Request $request, $id): RedirectResponse
|
||
|
{
|
||
|
$this->assetRepository->update($id, $request->all());
|
||
|
toastr()->success('Asset Updated Successfully.');
|
||
|
return redirect()->route('asset.index');
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Remove the specified resource from storage.
|
||
|
*/
|
||
|
public function destroy($id)
|
||
|
{
|
||
|
//
|
||
|
}
|
||
|
}
|