Compare commits

..

No commits in common. "df05cd21f4dfcaada00e89bdae2207912bea85cf" and "a7b2fd58d50cd0b06e3eaf24c8647cb712984e03" have entirely different histories.

3 changed files with 40 additions and 23 deletions

View File

@ -12,10 +12,6 @@ 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');
@ -24,8 +20,9 @@ class ReceptionScreenController extends Controller
public function create(): View
{
abort_if(Auth::guest(), 403);
if (Auth::guest()) {
abort(403);
}
$receptionScreens = ReceptionScreen::all()->sortBy('position');
return view('admin-reception-screen.create', compact('receptionScreens'));
}
@ -42,8 +39,6 @@ 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');

View File

@ -15,22 +15,26 @@ use Illuminate\Support\Str;
class UserController extends Controller
{
public function __construct()
{
$this->middleware('auth');
}
public function index(): View|Application|Factory|\Illuminate\Contracts\Foundation\Application
{
abort_if(!Auth::user('admin'), 403);
if (!Auth::user('admin')) {
abort(403, 'У вас нет прав доступа');
}
if (Auth::guest()) {
abort(403, 'Вы не авторизованы!');
}
$users = User::all();
return view('users.index', compact('users'));
}
public function store(UpdateUserRequest $request): RedirectResponse
{
abort_if(!Auth::user('admin'), 403);
if (Auth::guest()) {
abort(403, 'Вы не авторизованы!');
}
if (!Auth::user('admin')) {
abort(403, 'У вас нет прав доступа');
}
$validated = $request->validated();
$user = new User();
@ -44,21 +48,34 @@ class UserController extends Controller
public function create(): View|Application|Factory|\Illuminate\Contracts\Foundation\Application
{
abort_if(!Auth::user('admin'), 403);
if (!Auth::user('admin')) {
abort(403, 'У вас нет прав доступа');
}
if (Auth::guest()) {
abort(403, 'Вы не авторизованы!');
}
return view('users.create');
}
public function edit(User $user): View|Application|Factory|\Illuminate\Contracts\Foundation\Application
{
abort_if(!Auth::user('admin'), 403);
if (!Auth::user('admin')) {
abort(403, 'У вас нет прав доступа');
}
if (Auth::guest()) {
abort(403, 'Вы не авторизованы!');
}
return view('users.edit', compact('user'));
}
public function update(UpdateUserRequest $request, User $user): RedirectResponse
{
abort_if(!Auth::user('admin'), 403);
if (!Auth::user('admin')) {
abort(403, 'У вас нет прав доступа');
}
if (Auth::guest()) {
abort(403, 'Вы не авторизованы!');
}
$validated = $request->validated();
@ -73,8 +90,12 @@ class UserController extends Controller
public function destroy(User $user): RedirectResponse
{
abort_if(!Auth::user('admin'), 403);
if (!Auth::user('admin')) {
abort(403, 'У вас нет прав доступа');
}
if (Auth::guest()) {
abort(403, 'Вы не авторизованы!');
}
$user->delete();
return redirect()->route('users.index');

View File

@ -50,6 +50,7 @@
<aside class="list-group col-2">
<ul>
<li class="list-group-item"><a href="{{ route('admin-reception-screen.index') }}">Экран Приема</a></li>
<li class="list-group-item"><a href="">Дни открытых дверей</a></li>
@if(!is_null(Auth::getUser()) && Auth::getUser()->name === 'admin')
<li class="list-group-item"></li>
<li class="list-group-item"><a href="{{ route('users.index') }}">Список администраторов</a></li>