add middleware auth, optimize abort_if

This commit is contained in:
aslan 2024-01-25 10:51:29 +03:00
parent 52d2073dee
commit 956681c0b3
1 changed files with 8 additions and 3 deletions

View File

@ -12,6 +12,10 @@ use Illuminate\Support\Facades\Auth;
class ReceptionScreenController extends Controller
{
public function __construct()
{
$this->middleware('auth');
}
public function index(): View|Application|Factory|\Illuminate\Contracts\Foundation\Application
{
$receptionScreens = ReceptionScreen::all()->sortBy('position');
@ -20,9 +24,8 @@ class ReceptionScreenController extends Controller
public function create(): View
{
if (Auth::guest()) {
abort(403);
}
abort_if(Auth::guest(), 403);
$receptionScreens = ReceptionScreen::all()->sortBy('position');
return view('admin-reception-screen.create', compact('receptionScreens'));
}
@ -39,6 +42,8 @@ class ReceptionScreenController extends Controller
}
public function edit($id)
{
abort_if(Auth::guest(), 403);
$receptionScreen = new ReceptionScreen();
$currentReceptionScreen = $receptionScreen->find($id);
$receptionScreens = $receptionScreen->all()->sortBy('position');