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

66 lines
2.0 KiB
PHP

<?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
{
$onlineDocuments = ReceptionScreen::all()->sortBy('position');
return view('admin-reception-screen.index', compact('onlineDocuments'));
}
public function create(): View
{
if (Auth::guest()) {
abort(403);
}
$receptionScreens = ReceptionScreen::all()->sortBy('position');
return view('admin-reception-screen.create', compact('receptionScreens'));
}
public function store(StoreReceptionScreenRequest $request)
{
if (Auth::guest()) {
abort(403, 'Вы не авторизованы!');
}
$validated = $request->validated();
$receptionScreen = new ReceptionScreen();
$receptionScreen->name = $validated['name'];
$receptionScreen->position = $validated['position'];
$receptionScreen->save();
return redirect()->route('admin-reception-screen.index');
}
public function edit(ReceptionScreen $currentOnlineDocument)
{
if (Auth::guest()) {
abort(403, 'Вы не авторизованы!');
}
$onlineDocuments = ReceptionScreen::all()->sortBy('position');
return view('admin-reception-screen.edit', compact('currentOnlineDocument', 'onlineDocuments'));
}
public function update(UpdateReceptionScreenRequest $request, ReceptionScreen $doceumentsOnline)
{
//
}
/**
* Remove the specified resource from storage.
*/
public function destroy(ReceptionScreen $doceumentsOnline)
{
//
}
}