applicant-site/app/Http/Controllers/ReceptionScreenController.php

66 lines
2.0 KiB
PHP
Raw Normal View History

2024-01-23 11:20:15 +03:00
<?php
namespace App\Http\Controllers;
use App\Http\Requests\StoreReceptionScreenRequest;
use App\Http\Requests\UpdateReceptionScreenRequest;
use App\Models\ReceptionScreen;
use Illuminate\Contracts\View\Factory;
use Illuminate\Contracts\View\View;
use Illuminate\Foundation\Application;
use Illuminate\Support\Facades\Auth;
class ReceptionScreenController extends Controller
{
public function index(): View|Application|Factory|\Illuminate\Contracts\Foundation\Application
{
2024-01-23 17:58:48 +03:00
$onlineDocuments = ReceptionScreen::all()->sortBy('position');
2024-01-23 11:20:15 +03:00
return view('admin-reception-screen.index', compact('onlineDocuments'));
}
2024-01-24 15:41:20 +03:00
public function create(): View
2024-01-23 11:20:15 +03:00
{
if (Auth::guest()) {
abort(403);
}
2024-01-25 08:59:34 +03:00
$receptionScreens = ReceptionScreen::all()->sortBy('position');
return view('admin-reception-screen.create', compact('receptionScreens'));
2024-01-23 11:20:15 +03:00
}
public function store(StoreReceptionScreenRequest $request)
{
2024-01-25 08:59:34 +03:00
if (Auth::guest()) {
abort(403, 'Вы не авторизованы!');
}
2024-01-23 11:20:15 +03:00
2024-01-25 08:59:34 +03:00
$validated = $request->validated();
$receptionScreen = new ReceptionScreen();
$receptionScreen->name = $validated['name'];
$receptionScreen->position = $validated['position'];
$receptionScreen->save();
2024-01-23 11:20:15 +03:00
2024-01-25 08:59:34 +03:00
return redirect()->route('admin-reception-screen.index');
}
public function edit(ReceptionScreen $currentOnlineDocument)
2024-01-23 11:20:15 +03:00
{
2024-01-25 08:59:34 +03:00
if (Auth::guest()) {
abort(403, 'Вы не авторизованы!');
}
$onlineDocuments = ReceptionScreen::all()->sortBy('position');
return view('admin-reception-screen.edit', compact('currentOnlineDocument', 'onlineDocuments'));
2024-01-23 11:20:15 +03:00
}
public function update(UpdateReceptionScreenRequest $request, ReceptionScreen $doceumentsOnline)
{
//
}
/**
* Remove the specified resource from storage.
*/
public function destroy(ReceptionScreen $doceumentsOnline)
{
//
}
}