2024-04-04 10:35:27 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Modules\Leave\Http\Controllers;
|
|
|
|
|
|
|
|
use App\Http\Controllers\Controller;
|
|
|
|
use Illuminate\Http\RedirectResponse;
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
use Modules\Leave\Repositories\LeaveInterface;
|
|
|
|
|
|
|
|
class LeaveController extends Controller
|
|
|
|
{
|
|
|
|
private LeaveInterface $leaveRepository;
|
|
|
|
|
|
|
|
public function __construct(LeaveInterface $leaveRepository)
|
|
|
|
{
|
|
|
|
$this->leaveRepository = $leaveRepository;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Display a listing of the resource.
|
|
|
|
*/
|
|
|
|
public function index()
|
|
|
|
{
|
|
|
|
$data['leaves'] = $this->leaveRepository->findAll();
|
2024-04-04 12:08:23 +00:00
|
|
|
// dd($data['leaves']);
|
2024-04-04 10:35:27 +00:00
|
|
|
return view('leave::index');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show the form for creating a new resource.
|
|
|
|
*/
|
|
|
|
public function create()
|
|
|
|
{
|
|
|
|
$data['title'] = 'Create Leave';
|
|
|
|
return view('leave::create', $data);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Store a newly created resource in storage.
|
|
|
|
*/
|
|
|
|
public function store(Request $request): RedirectResponse
|
|
|
|
{
|
2024-04-04 12:08:23 +00:00
|
|
|
$inputData = $request->all();
|
|
|
|
try {
|
|
|
|
$this->leaveRepository->create($inputData);
|
|
|
|
toastr()->success('Leave Created Succesfully');
|
|
|
|
} catch (\Throwable $th) {
|
|
|
|
toastr()->error($th->getMessage());
|
|
|
|
}
|
|
|
|
return redirect()->route('leave.index');
|
2024-04-04 10:35:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show the specified resource.
|
|
|
|
*/
|
|
|
|
public function show($id)
|
|
|
|
{
|
|
|
|
return view('leave::show');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show the form for editing the specified resource.
|
|
|
|
*/
|
|
|
|
public function edit($id)
|
|
|
|
{
|
|
|
|
return view('leave::edit');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Update the specified resource in storage.
|
|
|
|
*/
|
|
|
|
public function update(Request $request, $id): RedirectResponse
|
|
|
|
{
|
|
|
|
//
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove the specified resource from storage.
|
|
|
|
*/
|
|
|
|
public function destroy($id)
|
|
|
|
{
|
|
|
|
//
|
|
|
|
}
|
|
|
|
}
|