* - directory refactor * - readme.md update * Update readme.md Co-authored-by: Adrian Hopek <adrian.hopek@blumilk.pl> * Update readme.md Co-authored-by: Ewelina Lasowy <56546832+EwelinaLasowy@users.noreply.github.com> * Update readme.md Co-authored-by: Ewelina Lasowy <56546832+EwelinaLasowy@users.noreply.github.com> * Update readme.md Co-authored-by: Ewelina Lasowy <56546832+EwelinaLasowy@users.noreply.github.com> * Update readme.md Co-authored-by: Adrian Hopek <adrian.hopek@blumilk.pl> Co-authored-by: Ewelina Lasowy <56546832+EwelinaLasowy@users.noreply.github.com>
		
			
				
	
	
		
			66 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			66 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| 
 | |
| declare(strict_types=1);
 | |
| 
 | |
| namespace Toby\Infrastructure\Http\Controllers;
 | |
| 
 | |
| use Illuminate\Http\RedirectResponse;
 | |
| use Inertia\Response;
 | |
| use Toby\Eloquent\Models\Holiday;
 | |
| use Toby\Infrastructure\Http\Requests\HolidayRequest;
 | |
| use Toby\Infrastructure\Http\Resources\HolidayFormDataResource;
 | |
| use Toby\Infrastructure\Http\Resources\HolidayResource;
 | |
| 
 | |
| class HolidayController extends Controller
 | |
| {
 | |
|     public function index(): Response
 | |
|     {
 | |
|         $holidays = Holiday::query()
 | |
|             ->orderBy("date")
 | |
|             ->get();
 | |
| 
 | |
|         return inertia("Holidays/Index", [
 | |
|             "holidays" => HolidayResource::collection($holidays),
 | |
|         ]);
 | |
|     }
 | |
| 
 | |
|     public function create(): Response
 | |
|     {
 | |
|         return inertia("Holidays/Create");
 | |
|     }
 | |
| 
 | |
|     public function store(HolidayRequest $request): RedirectResponse
 | |
|     {
 | |
|         Holiday::query()->create($request->data());
 | |
| 
 | |
|         return redirect()
 | |
|             ->route("holidays.index")
 | |
|             ->with("success", __("Holiday has been created"));
 | |
|     }
 | |
| 
 | |
|     public function edit(Holiday $holiday): Response
 | |
|     {
 | |
|         return inertia("Holidays/Edit", [
 | |
|             "holiday" => new HolidayFormDataResource($holiday),
 | |
|         ]);
 | |
|     }
 | |
| 
 | |
|     public function update(HolidayRequest $request, Holiday $holiday): RedirectResponse
 | |
|     {
 | |
|         $holiday->update($request->data());
 | |
| 
 | |
|         return redirect()
 | |
|             ->route("holidays.index")
 | |
|             ->with("success", __("Holiday has been updated"));
 | |
|     }
 | |
| 
 | |
|     public function destroy(Holiday $holiday): RedirectResponse
 | |
|     {
 | |
|         $holiday->delete();
 | |
| 
 | |
|         return redirect()
 | |
|             ->route("holidays.index")
 | |
|             ->with("success", __("Holiday has been deleted"));
 | |
|     }
 | |
| }
 |