StocksNew/Modules/Asset/app/Http/Controllers/AssetDemandController.php

92 lines
2.5 KiB
PHP
Raw Normal View History

2024-08-27 12:03:06 +00:00
<?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\AssetDemandInterface;
use Modules\Asset\Repositories\AssetDemandRepository;
use Modules\Asset\Repositories\AssetInterface;
use Modules\Asset\Repositories\AssetRepository;
class AssetDemandController extends Controller
{
private $assetDemandRepository;
private $assetRepository;
public function __construct(AssetDemandInterface $assetDemandRepository, AssetInterface $assetRepository)
{
$this->assetDemandRepository = $assetDemandRepository;
$this->assetRepository = $assetRepository;
}
/**
* Display a listing of the resource.
*/
public function index()
{
$data['title'] = "AssetDemand Lists";
$data['assetDemandLists'] = $this->assetDemandRepository->findAll();
return view('asset::assetdemands.index', $data);
}
/**
* Show the form for creating a new resource.
*/
public function create()
{
$data['title'] = "Create assetDemand";
$data['editable'] = false;
$data['availableAssetLists'] = $this->assetRepository->pluckAvailable();
return view('asset::assetdemands.create', $data);
}
/**
* Store a newly created resource in storage.
*/
public function store(Request $request): RedirectResponse
{
$this->assetDemandRepository->create($request->all());
toastr()->success('assetDemand Created Successfully.');
return redirect()->route('assetDemand.index');
}
/**
* Show the specified resource.
*/
public function show($id)
{
return view('asset::assetdemands.show');
}
/**
* Show the form for editing the specified resource.
*/
public function edit($id)
{
$data['title'] = "Edit assetDemand";
$data['editable'] = true;
$data['assetDemand'] = $this->assetDemandRepository->getassetDemandById($id);
return view('asset::assetdemands.edit', $data);
}
/**
* Update the specified resource in storage.
*/
public function update(Request $request, $id): RedirectResponse
{
$this->assetDemandRepository->update($id, $request->all());
toastr()->success('assetDemand Updated Successfully.');
return redirect()->route('assetDemand.index');
}
/**
* Remove the specified resource from storage.
*/
public function destroy($id)
{
//
}
}