|
1 | 1 | <?php
|
2 | 2 |
|
3 | 3 | use Illuminate\Support\Facades\Route;
|
4 |
| -use App\Http\Controllers\AuthController; |
| 4 | + |
5 | 5 | use App\Http\Middleware\CheckPermission;
|
| 6 | + |
| 7 | +use App\Http\Controllers\AuthController; |
6 | 8 | use App\Http\Controllers\KhoaController;
|
7 | 9 | use App\Http\Controllers\NganhController;
|
8 | 10 | use App\Http\Controllers\LopController;
|
|
19 | 21 |
|
20 | 22 | Route::get('/', function () {
|
21 | 23 | return view('index');
|
22 |
| -}); |
23 |
| - |
24 |
| -Route::get('/dashboard', function () { |
25 |
| - return view('dashboard.index'); |
26 |
| -}); |
| 24 | +})->name('index');; |
27 | 25 |
|
28 | 26 | // admin login
|
29 | 27 | Route::get('login', [AuthController::class, 'showLoginForm'])->name('login');
|
|
32 | 30 | Route::post('register', [AuthController::class, 'register']);
|
33 | 31 | Route::get('logout', [AuthController::class, 'logout'])->name('logout');
|
34 | 32 |
|
35 |
| -// Khoa |
36 |
| -Route::get('/khoa', [KhoaController::class, 'index'])->name('khoa.index'); |
| 33 | +//Route::middleware('auth')->group(function () { |
| 34 | + // có quyền admin mới được truy cập |
| 35 | + // Route::middleware([CheckPermission::class . ':admin'])->group(function () { |
| 36 | + //}); |
| 37 | + //Route::middleware([CheckPermission::class . ':user'])->group(function () { |
| 38 | + //}); |
| 39 | + //}); |
| 40 | + |
| 41 | + |
| 42 | +Route::middleware('auth')->group(function () { |
| 43 | + // Route yêu cầu người dùng có quyền là 'user' |
| 44 | + Route::middleware([CheckPermission::class . ':user'])->group(function () { |
| 45 | + Route::get('/dashboard', function () { |
| 46 | + return view('dashboard.index'); // Đảm bảo bạn có view 'dashboard.index' |
| 47 | + })->name('dashboard'); // Đặt tên route là 'dashboard' |
| 48 | + }); |
| 49 | +}); |
37 | 50 |
|
38 | 51 | // Login và có quyền admin
|
39 |
| -// Route::middleware(['auth', CheckPermission::class . ':admin'])->group(function () { |
| 52 | +Route::middleware(['auth', CheckPermission::class . ':admin'])->group(function () { |
| 53 | + |
| 54 | + // Khoa |
| 55 | + Route::get('/khoa', [KhoaController::class, 'index'])->name('khoa.index'); |
40 | 56 | Route::get('/khoa/create', [KhoaController::class, 'create'])->name('khoa.create');
|
41 | 57 | Route::get('/khoa/{id}/edit', [KhoaController::class, 'edit'])->name('khoa.edit');
|
42 | 58 | Route::post('/khoa', [KhoaController::class, 'store'])->name('khoa.store');
|
43 | 59 | Route::put('/khoa/{id}', [KhoaController::class, 'update'])->name('khoa.update');
|
44 | 60 | Route::delete('/khoa/{id}', [KhoaController::class, 'destroy'])->name('khoa.destroy');
|
45 |
| - |
46 | 61 | Route::get('/khoa/timkiem', [KhoaController::class, 'search'])->name('khoa.search');
|
47 |
| -//}); |
48 |
| - |
49 |
| -// Nghành |
50 |
| -Route::get('/nganh', [NganhController::class, 'index'])->name('nganh.index'); |
51 |
| -Route::get('/nganh/search', [NganhController::class, 'search'])->name('nganh.search'); |
52 |
| -Route::get('/nganh/create', [NganhController::class, 'create'])->name('nganh.create'); |
53 |
| -Route::post('/nganh', [NganhController::class, 'store'])->name('nganh.store'); |
54 |
| -Route::get('/nganh/{id}/edit', [NganhController::class, 'edit'])->name('nganh.edit'); |
55 |
| -Route::put('/nganh/{id}', [NganhController::class, 'update'])->name('nganh.update'); |
56 |
| -Route::delete('/nganh/{id}', [NganhController::class, 'destroy'])->name('nganh.destroy'); |
57 |
| - |
58 |
| -// lớp |
59 |
| -Route::get('/lop', [LopController::class, 'index'])->name('lop.index'); |
60 |
| -Route::get('/lop/timkiem', [LopController::class, 'search'])->name('lop.search'); |
61 |
| -Route::get('/lop/create', [LopController::class, 'create'])->name('lop.create'); |
62 |
| -Route::post('/lop', [LopController::class, 'store'])->name('lop.store'); |
63 |
| -Route::get('/lop/{id}/edit', [LopController::class, 'edit'])->name('lop.edit'); |
64 |
| -Route::put('/lop/{id}', [LopController::class, 'update'])->name('lop.update'); |
65 |
| -Route::delete('/lop/{id}', [LopController::class, 'destroy'])->name('lop.destroy'); |
66 |
| - |
67 |
| -// Sinh viên |
68 |
| -Route::get('/sinhvien', [SinhVienController::class, 'index'])->name('sinhvien.index'); |
69 |
| -Route::get('/sinhvien/search', [SinhVienController::class, 'search'])->name('sinhvien.search'); |
70 |
| -Route::get('/sinhvien/create', [SinhVienController::class, 'create'])->name('sinhvien.create'); |
71 |
| -Route::post('/sinhvien', [SinhVienController::class, 'store'])->name('sinhvien.store'); |
72 |
| -Route::get('/sinhvien/{id}/edit', [SinhVienController::class, 'edit'])->name('sinhvien.edit'); |
73 |
| -Route::put('/sinhvien/{id}', [SinhVienController::class, 'update'])->name('sinhvien.update'); |
74 |
| -Route::delete('/sinhvien/{id}', [SinhVienController::class, 'destroy'])->name('sinhvien.destroy'); |
75 |
| - |
76 |
| -// Môn học |
77 |
| -Route::get('/monhoc', [MonHocController::class, 'index'])->name('monhoc.index'); |
78 |
| -Route::get('/monhoc/search', [MonHocController::class, 'search'])->name('monhoc.search'); |
79 |
| -Route::get('/monhoc/create', [MonHocController::class, 'create'])->name('monhoc.create'); |
80 |
| -Route::post('/monhoc', [MonHocController::class, 'store'])->name('monhoc.store'); |
81 |
| -Route::get('/monhoc/{id}/edit', [MonHocController::class, 'edit'])->name('monhoc.edit'); |
82 |
| -Route::put('/monhoc/{id}', [MonHocController::class, 'update'])->name('monhoc.update'); |
83 |
| -Route::delete('/monhoc/{id}', [MonHocController::class, 'destroy'])->name('monhoc.destroy'); |
| 62 | + |
| 63 | + // Nghành |
| 64 | + Route::get('/nganh', [NganhController::class, 'index'])->name('nganh.index'); |
| 65 | + Route::get('/nganh/search', [NganhController::class, 'search'])->name('nganh.search'); |
| 66 | + Route::get('/nganh/create', [NganhController::class, 'create'])->name('nganh.create'); |
| 67 | + Route::post('/nganh', [NganhController::class, 'store'])->name('nganh.store'); |
| 68 | + Route::get('/nganh/{id}/edit', [NganhController::class, 'edit'])->name('nganh.edit'); |
| 69 | + Route::put('/nganh/{id}', [NganhController::class, 'update'])->name('nganh.update'); |
| 70 | + Route::delete('/nganh/{id}', [NganhController::class, 'destroy'])->name('nganh.destroy'); |
| 71 | + |
| 72 | + // lớp |
| 73 | + Route::get('/lop', [LopController::class, 'index'])->name('lop.index'); |
| 74 | + Route::get('/lop/timkiem', [LopController::class, 'search'])->name('lop.search'); |
| 75 | + Route::get('/lop/create', [LopController::class, 'create'])->name('lop.create'); |
| 76 | + Route::post('/lop', [LopController::class, 'store'])->name('lop.store'); |
| 77 | + Route::get('/lop/{id}/edit', [LopController::class, 'edit'])->name('lop.edit'); |
| 78 | + Route::put('/lop/{id}', [LopController::class, 'update'])->name('lop.update'); |
| 79 | + Route::delete('/lop/{id}', [LopController::class, 'destroy'])->name('lop.destroy'); |
| 80 | + |
| 81 | + // Sinh viên |
| 82 | + Route::get('/sinhvien', [SinhVienController::class, 'index'])->name('sinhvien.index'); |
| 83 | + Route::get('/sinhvien/search', [SinhVienController::class, 'search'])->name('sinhvien.search'); |
| 84 | + Route::get('/sinhvien/create', [SinhVienController::class, 'create'])->name('sinhvien.create'); |
| 85 | + Route::post('/sinhvien', [SinhVienController::class, 'store'])->name('sinhvien.store'); |
| 86 | + Route::get('/sinhvien/{id}/edit', [SinhVienController::class, 'edit'])->name('sinhvien.edit'); |
| 87 | + Route::put('/sinhvien/{id}', [SinhVienController::class, 'update'])->name('sinhvien.update'); |
| 88 | + Route::delete('/sinhvien/{id}', [SinhVienController::class, 'destroy'])->name('sinhvien.destroy'); |
| 89 | + |
| 90 | + // Môn học |
| 91 | + Route::get('/monhoc', [MonHocController::class, 'index'])->name('monhoc.index'); |
| 92 | + Route::get('/monhoc/search', [MonHocController::class, 'search'])->name('monhoc.search'); |
| 93 | + Route::get('/monhoc/create', [MonHocController::class, 'create'])->name('monhoc.create'); |
| 94 | + Route::post('/monhoc', [MonHocController::class, 'store'])->name('monhoc.store'); |
| 95 | + Route::get('/monhoc/{id}/edit', [MonHocController::class, 'edit'])->name('monhoc.edit'); |
| 96 | + Route::put('/monhoc/{id}', [MonHocController::class, 'update'])->name('monhoc.update'); |
| 97 | + Route::delete('/monhoc/{id}', [MonHocController::class, 'destroy'])->name('monhoc.destroy'); |
| 98 | + |
| 99 | +}); |
84 | 100 |
|
85 | 101 | // câu hỏi
|
86 | 102 | Route::get('/cauhoi', [CauHoiController::class, 'index'])->name('cauhoi.index');
|
|
0 commit comments