refactoring User resource
Tests & Lint & Deploy to Railway / build (2.6.6, 20.x, 8.3) (push) Failing after 6m52s Details
Tests & Lint & Deploy to Railway / deploy (push) Has been skipped Details

This commit is contained in:
aslan 2024-02-14 09:54:11 +03:00
parent 2a21e25200
commit fc706fce82
1 changed files with 6 additions and 10 deletions

View File

@ -1,10 +1,10 @@
<?php
namespace App\Http\Controllers;
namespace App\Http\Controllers\admin;
use App\Http\Requests\UpdateUserRequest;
use App\Http\Controllers\Controller;
use App\Http\Requests\admin\UpdateUserRequest;
use App\Models\User;
use Illuminate\Auth\Events\PasswordReset;
use Illuminate\Contracts\View\Factory;
use Illuminate\Contracts\View\View;
use Illuminate\Foundation\Application;
@ -15,16 +15,12 @@ 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()->name !== 'admin', 403);
$users = User::all();
return view('users.index', compact('users'));
return view('admin.users.index', compact('users'));
}
public function store(UpdateUserRequest $request): RedirectResponse
@ -46,14 +42,14 @@ class UserController extends Controller
{
abort_if(Auth::user()->name !== 'admin', 403);
return view('users.create');
return view('admin.users.create');
}
public function edit(User $user): View|Application|Factory|\Illuminate\Contracts\Foundation\Application
{
abort_if(Auth::user()->name !== 'admin', 403);
return view('users.edit', compact('user'));
return view('admin.users.edit', compact('user'));
}
public function update(UpdateUserRequest $request, User $user): RedirectResponse