forked from aslan/applicant-site
add middleware auth, optimize abort_if
This commit is contained in:
parent
52d2073dee
commit
956681c0b3
|
@ -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');
|
||||
|
|
Loading…
Reference in New Issue