UsersController.php
1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use App\Models\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class UsersController extends Controller
{
public function index(Request $request) {
$title = 'Админка - Пользователи системы';
$id_admin = Auth::user()->id;
if ($request->ajax()) {
$user = User::find($request->id);
$request->offsetUnset('id');
$user->update($request->all());
}
$users = User::query()->paginate(15);
if ($request->ajax()) {
return view('admin.users.index_ajax', compact('users', 'id_admin'));
} else {
return view('admin.users.index', compact('users', 'title', 'id_admin'));
}
}
public function roles(Request $request) {
if ($request->ajax()) {
$user = User::find($request->id);
$request->offsetUnset('id');
$user->update($request->all());
}
$users = User::query()->paginate(15);
if ($request->ajax()) {
return view('admin.users.roles.index_ajax', compact('users'));
} else {
return view('admin.users.roles.index', compact('users'));
}
}
}