2024-04-15 08:02:40 +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\TransferRepository;
|
|
|
|
|
|
|
|
class TransferController extends Controller
|
|
|
|
{
|
|
|
|
private $transferRepository;
|
|
|
|
|
|
|
|
public function __construct(TransferRepository $transferRepository)
|
|
|
|
{
|
|
|
|
$this->transferRepository = $transferRepository;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Display a listing of the resource.
|
|
|
|
*/
|
|
|
|
public function index()
|
|
|
|
{
|
|
|
|
$data['title'] = 'Transfer Lists';
|
|
|
|
$data['transferLists'] = $this->transferRepository->findAll();
|
|
|
|
return view('admin::transfers.index', $data);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show the form for creating a new resource.
|
|
|
|
*/
|
|
|
|
public function create()
|
|
|
|
{
|
2024-04-15 12:16:31 +00:00
|
|
|
$data['title'] = 'Create Transfer';
|
2024-04-15 08:02:40 +00:00
|
|
|
$data['editable'] = false;
|
|
|
|
return view('admin::transfers.create', $data);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Store a newly created resource in storage.
|
|
|
|
*/
|
|
|
|
public function store(Request $request): RedirectResponse
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
$this->transferRepository->create($request->all());
|
|
|
|
toastr()->success('Transfer Created Successfully');
|
|
|
|
|
|
|
|
} catch (\Throwable $th) {
|
|
|
|
toastr()->error($th->getMessage());
|
|
|
|
}
|
|
|
|
return redirect()->route('transfer.index');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show the specified resource.
|
|
|
|
*/
|
|
|
|
public function show($id)
|
|
|
|
{
|
|
|
|
return view('admin::transfers.show');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show the form for editing the specified resource.
|
|
|
|
*/
|
|
|
|
public function edit($id)
|
|
|
|
{
|
|
|
|
try {
|
2024-04-15 12:16:31 +00:00
|
|
|
$data['title'] = 'Edit Transfer';
|
2024-04-15 08:02:40 +00:00
|
|
|
$data['editable'] = true;
|
|
|
|
$data['transfer'] = $this->transferRepository->getTransferById($id);
|
|
|
|
|
|
|
|
} catch (\Throwable $th) {
|
|
|
|
toastr()->error($th->getMessage());
|
|
|
|
}
|
|
|
|
|
|
|
|
return view('admin::transfers.edit', $data);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Update the specified resource in storage.
|
|
|
|
*/
|
|
|
|
public function update(Request $request, $id): RedirectResponse
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
|
|
|
|
$this->transferRepository->update($id, $request->all());
|
|
|
|
toastr()->success('Transfer Updated Successfully');
|
|
|
|
|
|
|
|
} catch (\Throwable $th) {
|
|
|
|
toastr()->error($th->getMessage());
|
|
|
|
}
|
|
|
|
return redirect()->route('transfer.index');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove the specified resource from storage.
|
|
|
|
*/
|
|
|
|
public function destroy($id)
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
$this->transferRepository->delete($id);
|
|
|
|
toastr()->success('Transfer Deleted Successfully');
|
|
|
|
} catch (\Throwable $th) {
|
|
|
|
toastr()->error($th->getMessage());
|
|
|
|
}
|
|
|
|
return redirect()->route('transfer.index');
|
|
|
|
}
|
|
|
|
}
|