first commit
This commit is contained in:
98
Modules/Asset/app/Http/Controllers/AssetController.php
Normal file
98
Modules/Asset/app/Http/Controllers/AssetController.php
Normal file
@ -0,0 +1,98 @@
|
||||
<?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)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user