Commit ad6e7ea05454de0abd71cd1f7045a222bf2209c9

Authored by Андрей Ларионов
1 parent 6a962b0098

Правки авторизации и регистрации администратора

Showing 5 changed files with 33 additions and 5 deletions Inline Diff

app/Http/Controllers/Admin/AdminController.php
1 <?php 1 <?php
2 2
3 namespace App\Http\Controllers\Admin; 3 namespace App\Http\Controllers\Admin;
4 4
5 use App\Http\Controllers\Controller; 5 use App\Http\Controllers\Controller;
6 use App\Http\Requests\CompanyRequest; 6 use App\Http\Requests\CompanyRequest;
7 use App\Models\Company; 7 use App\Models\Company;
8 use App\Models\Employer; 8 use App\Models\Employer;
9 use App\Models\User; 9 use App\Models\User;
10 use Carbon\Carbon;
10 use Illuminate\Http\Request; 11 use Illuminate\Http\Request;
11 use Illuminate\Support\Facades\Auth; 12 use Illuminate\Support\Facades\Auth;
12 use Illuminate\Support\Facades\Hash; 13 use Illuminate\Support\Facades\Hash;
13 use Illuminate\Support\Facades\Storage; 14 use Illuminate\Support\Facades\Storage;
14 use Illuminate\Support\Facades\Validator; 15 use Illuminate\Support\Facades\Validator;
15 16
16 class AdminController extends Controller 17 class AdminController extends Controller
17 { 18 {
18 /** 19 /**
19 * Handle the incoming request. 20 * Handle the incoming request.
20 * 21 *
21 * @param \Illuminate\Http\Request $request 22 * @param \Illuminate\Http\Request $request
22 * @return \Illuminate\Http\Response 23 * @return \Illuminate\Http\Response
23 */ 24 */
24 public function __invoke(Request $request) 25 public function __invoke(Request $request)
25 { 26 {
26 // 27 //
27 } 28 }
28 29
29 public function register() { 30 public function register() {
30 return view('admin.register'); 31 return view('admin.register');
31 } 32 }
32 33
33 public function create(Request $request) { 34 public function create(Request $request) {
34 35
35 $rules = [ 36 $rules = [
36 'name' => 'required|string|max:255', 37 'name' => 'required|string|max:255',
37 'email' => 'required|string|email|max:255|unique:users', 38 'email' => 'required|string|email|max:255|unique:users',
38 'password' => 'required|string|min:8|confirmed', 39 'password' => 'required|string|min:8|confirmed',
39 ]; 40 ];
40 41
41 $messages = [ 42 $messages = [
42 'required' => 'Укажите обязательное поле «:attribute»', 43 'required' => 'Укажите обязательное поле «:attribute»',
43 'confirmed' => 'Пароли не совпадают', 44 'confirmed' => 'Пароли не совпадают',
44 'email' => 'Введите корректный email', 45 'email' => 'Введите корректный email',
46 'unique' => 'Данный email занят уже',
45 'min' => [ 47 'min' => [
46 'string' => 'Поле «:attribute» должно быть не меньше :min символов', 48 'string' => 'Поле «:attribute» должно быть не меньше :min символов',
47 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' 49 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт'
48 ], 50 ],
49 'max' => [ 51 'max' => [
50 'string' => 'Поле «:attribute» должно быть не больше :max символов', 52 'string' => 'Поле «:attribute» должно быть не больше :max символов',
51 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' 53 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт'
52 ], 54 ],
53 ]; 55 ];
54 56
55 $validator = Validator::make($request->all(), $rules, $messages); 57 $validator = Validator::make($request->all(), $rules, $messages);
56 58
57 if ($validator->fails()) { 59 if ($validator->fails()) {
58 return back()->withErrors($validator)->withInput(); //->route('admin.register') 60 return back()->withErrors($validator)->withInput(); //->route('admin.register')
59 61
60 } else { 62 } else {
61 $params = $request->all(); 63 $params = $request->all();
62 64
63 User::create([ 65 User::create([
64 'name' => $request->name, 66 'name' => $request->name,
65 'email' => $request->email, 67 'email' => $request->email,
66 'password' => Hash::make($request->password), 68 'password' => Hash::make($request->password),
69 'admin' => '1',
70 'email_verified_at' => Carbon::now()
71
67 ]); 72 ]);
68 return redirect() 73 return redirect()
69 ->route('admin.login') 74 ->route('admin.login')
70 ->with('success', 'Вы успешно зарегистрировались'); 75 ->with('success', 'Вы успешно зарегистрировались');
71 } 76 }
72 } 77 }
73 78
74 public function login() { 79 public function login() {
75 return view('admin.login'); 80 return view('admin.login');
76 } 81 }
77 82
78 // Аутентификация 83 // Аутентификация
79 public function autenticate(Request $request) { 84 public function autenticate(Request $request) {
80 //$request->validate( 85 //$request->validate(
81 $rules = [ 86 $rules = [
82 'email' => 'required|string|email', 87 'email' => 'required|string|email',
83 'password' => 'required|string', 88 'password' => 'required|string',
84 ]; 89 ];
85 90
86 $messages = [ 91 $messages = [
87 'required' => 'Укажите обязательное поле «:attribute»', 92 'required' => 'Укажите обязательное поле «:attribute»',
88 'email' => 'Введите корректный email', 93 'email' => 'Введите корректный email',
89 'min' => [ 94 'min' => [
90 'string' => 'Поле «:attribute» должно быть не меньше :min символов', 95 'string' => 'Поле «:attribute» должно быть не меньше :min символов',
91 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' 96 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт'
92 ], 97 ],
93 'max' => [ 98 'max' => [
94 'string' => 'Поле «:attribute» должно быть не больше :max символов', 99 'string' => 'Поле «:attribute» должно быть не больше :max символов',
95 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' 100 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт'
96 ], 101 ],
97 ]; 102 ];
98 103
99 104
100 $validator = Validator::make($request->all(), $rules, $messages); 105 $validator = Validator::make($request->all(), $rules, $messages);
101 106
102 if ($validator->fails()) { 107 if ($validator->fails()) {
103 return back()->withErrors($validator)->withInput(); 108 return back()->withErrors($validator)->withInput();
104 109
105 } else { 110 } else {
106 111
107 $credentials = $request->only('email', 'password'); 112 $credentials = $request->only('email', 'password');
108 113
109 if (Auth::attempt($credentials, $request->has('remember'))) { 114 if (Auth::attempt($credentials, $request->has('remember'))) {
110 115
111 if (is_null(Auth::user()->email_verified_at)) { 116 if (is_null(Auth::user()->email_verified_at)) {
112 Auth::logout(); 117 Auth::logout();
113 return back()->withErrors('Адрес почты не подтвержден')->withInput(); 118 return back()->withErrors('Адрес почты не подтвержден')->withInput();
114 } 119 }
115 120
116 if (!Auth::user()->admin) { 121 if (!Auth::user()->admin) {
117 Auth::logout(); 122 Auth::logout();
118 return //redirect()->route('admin.login') 123 return //redirect()->route('admin.login')
119 back()->withErrors('Вы не являетесь админом!')->withInput();; 124 back()->withErrors('Вы не являетесь админом!')->withInput();;
120 125
121 } 126 }
122 127
123 return redirect() 128 return redirect()
124 ->route('admin.index') 129 ->route('admin.index')
125 ->with('success', 'Вы вошли в личный кабинет.'); 130 ->with('success', 'Вы вошли в личный кабинет.');
126 } 131 }
127 } 132 }
128 133
129 return redirect() 134 return redirect()
130 ->route('admin.login') 135 ->route('admin.login')
131 ->withErrors('Неверный логин или пароль!')->withInput(); 136 ->withErrors('Неверный логин или пароль!')->withInput();
132 137
133 } 138 }
134 139
135 public function logout() { 140 public function logout() {
136 Auth::logout(); 141 Auth::logout();
137 return redirect()->route('index') 142 return redirect()->route('index')
138 ->with('success', 'Вы вышли из личного кабинета'); 143 ->with('success', 'Вы вышли из личного кабинета');
139 } 144 }
140 145
141 public function index() { 146 public function index() {
142 $all_user = User::query()->count(); 147 $all_user = User::query()->count();
143 $all_employer = User::where('is_worker', '0')->count(); 148 $all_employer = User::where('is_worker', '0')->count();
144 $all_worker = User::where('is_worker', '1')->count(); 149 $all_worker = User::where('is_worker', '1')->count();
145 $all_admin = User::where('admin', '1')->count(); 150 $all_admin = User::where('admin', '1')->count();
146 return view('admin.index', compact('all_employer', 'all_user', 'all_worker', 'all_admin')); 151 return view('admin.index', compact('all_employer', 'all_user', 'all_worker', 'all_admin'));
147 } 152 }
148 153
149 public function index_admin(Request $request) { 154 public function index_admin(Request $request) {
150 $title = 'Админка - Администраторы системы'; 155 $title = 'Админка - Администраторы системы';
151 $id_admin = Auth::user()->id; 156 $id_admin = Auth::user()->id;
152 157
153 if ($request->ajax()) { 158 if ($request->ajax()) {
154 $user = User::find($request->id); 159 $user = User::find($request->id);
155 $request->offsetUnset('id'); 160 $request->offsetUnset('id');
156 $user->update($request->all()); 161 $user->update($request->all());
157 } 162 }
158 $find_key = ''; 163 $find_key = '';
159 $users = User::where('admin', '1'); 164 $users = User::where('admin', '1');
160 if (isset($request->find)) { 165 if (isset($request->find)) {
161 $find_key = $request->find; 166 $find_key = $request->find;
162 $users = $users->where(function($query) use($find_key) { 167 $users = $users->where(function($query) use($find_key) {
163 $query->Where('name', 'LIKE', "%$find_key%") 168 $query->Where('name', 'LIKE', "%$find_key%")
164 ->orWhere('email', 'LIKE', "%$find_key%"); 169 ->orWhere('email', 'LIKE', "%$find_key%");
165 }); 170 });
166 } 171 }
167 $users = $users->paginate(15); 172 $users = $users->paginate(15);
168 173
169 if ($request->ajax()) { 174 if ($request->ajax()) {
170 return view('admin.users.index_ajax', compact('users', 'id_admin')); 175 return view('admin.users.index_ajax', compact('users', 'id_admin'));
171 } else { 176 } else {
172 return view('admin.users.index', compact('users', 'title', 'id_admin', 'find_key')); 177 return view('admin.users.index', compact('users', 'title', 'id_admin', 'find_key'));
173 } 178 }
174 } 179 }
175 180
176 //Страница профиль пользователя - форма 181 //Страница профиль пользователя - форма
177 public function profile_user(User $user) { 182 public function profile_user(User $user) {
178 $visible = false; 183 $visible = false;
179 if($user->is_worker) { 184 if($user->is_worker) {
180 $caption = "Карточка работника"; 185 $caption = "Карточка работника";
181 if (isset($user->workers[0]->id)) { 186 if (isset($user->workers[0]->id)) {
182 $link = route('admin.worker-profile-edit', ['worker' => $user->workers[0]->id]); 187 $link = route('admin.worker-profile-edit', ['worker' => $user->workers[0]->id]);
183 $visible = true; 188 $visible = true;
184 } else { 189 } else {
185 $link = ""; 190 $link = "";
186 } 191 }
187 192
188 } else { 193 } else {
189 $caption = "Карточка работодателя"; 194 $caption = "Карточка работодателя";
190 if (isset($user->employers[0]->id)) { 195 if (isset($user->employers[0]->id)) {
191 196
192 $link = route('admin.employer-profile', ['employer' => $user->employers[0]->id]); 197 $link = route('admin.employer-profile', ['employer' => $user->employers[0]->id]);
193 $visible = true; 198 $visible = true;
194 } else { 199 } else {
195 $link = ""; 200 $link = "";
196 } 201 }
197 } 202 }
198 203
199 return view('admin.users.profile', compact('user', 'visible', 'link', 'caption')); 204 return view('admin.users.profile', compact('user', 'visible', 'link', 'caption'));
200 } 205 }
201 206
202 //Страница профиль пользователя - сохранение формы 207 //Страница профиль пользователя - сохранение формы
203 public function store_profile_user(User $user, Request $request) { 208 public function store_profile_user(User $user, Request $request) {
204 $rules = [ 209 $rules = [
205 'name' => 'required|min:3', 210 'name' => 'required|min:3',
206 ]; 211 ];
207 $messages = [ 212 $messages = [
208 'required' => 'Укажите обязательное поле', 213 'required' => 'Укажите обязательное поле',
209 'email' => 'Это поле должно быть определено, как Email' 214 'email' => 'Это поле должно быть определено, как Email'
210 ]; 215 ];
211 $validator = Validator::make($request->all(), $rules, $messages); 216 $validator = Validator::make($request->all(), $rules, $messages);
212 217
213 if ($validator->fails()) { 218 if ($validator->fails()) {
214 return redirect()->route('admin.user-profile', ['user' => $user->id]) 219 return redirect()->route('admin.user-profile', ['user' => $user->id])
215 ->withErrors($validator); 220 ->withErrors($validator);
216 } else { 221 } else {
217 $user->update($request->all()); 222 $user->update($request->all());
218 return redirect()->route('admin.user-profile', ['user' => $user->id]) 223 return redirect()->route('admin.user-profile', ['user' => $user->id])
219 ->with('success', 'Данные были успешно сохранены'); 224 ->with('success', 'Данные были успешно сохранены');
220 } 225 }
221 return redirect()->route('admin.user-profile', ['user' => $user->id]); 226 return redirect()->route('admin.user-profile', ['user' => $user->id]);
222 } 227 }
223 228
224 // Страница профиль админа - форма 229 // Страница профиль админа - форма
225 public function profile() { 230 public function profile() {
226 $id = Auth::user()->id; 231 $id = Auth::user()->id;
227 $user = User::find($id); 232 $user = User::find($id);
228 233
229 return view('admin.profile', compact('user')); 234 return view('admin.profile', compact('user'));
230 } 235 }
231 236
232 // Страница профиль админа - сохранение формы 237 // Страница профиль админа - сохранение формы
233 public function store_profile(Request $request) { 238 public function store_profile(Request $request) {
234 $id = Auth::user()->id; 239 $id = Auth::user()->id;
235 $user = User::find($id); 240 $user = User::find($id);
236 241
237 $rules = [ 242 $rules = [
238 'name' => 'required|min:3', 243 'name' => 'required|min:3',
239 'email' => 'required|email|min:3', 244 'email' => 'required|email|min:3',
240 ]; 245 ];
241 $messages = [ 246 $messages = [
242 'required' => 'Укажите обязательное поле', 247 'required' => 'Укажите обязательное поле',
243 'email' => 'Это поле должно быть определено, как Email' 248 'email' => 'Это поле должно быть определено, как Email'
244 ]; 249 ];
245 $validator = Validator::make($request->all(), $rules, $messages); 250 $validator = Validator::make($request->all(), $rules, $messages);
246 251
247 if ($validator->fails()) { 252 if ($validator->fails()) {
248 return redirect()->route('admin.profile') 253 return redirect()->route('admin.profile')
249 ->withErrors($validator); 254 ->withErrors($validator);
250 } else { 255 } else {
251 $user->update($request->all()); 256 $user->update($request->all());
252 return redirect()->route('admin.profile') 257 return redirect()->route('admin.profile')
253 ->with('success', 'Данные были успешно сохранены'); 258 ->with('success', 'Данные были успешно сохранены');
254 } 259 }
255 return redirect()->route('admin.profile'); 260 return redirect()->route('admin.profile');
256 } 261 }
257 262
258 // Форма смены пароля администоратора 263 // Форма смены пароля администоратора
259 public function profile_password() { 264 public function profile_password() {
260 $id = Auth::user()->id; 265 $id = Auth::user()->id;
261 $user = User::find($id); 266 $user = User::find($id);
262 $username = $user->name; 267 $username = $user->name;
263 268
264 return view('admin.password', compact('username')); 269 return view('admin.password', compact('username'));
265 } 270 }
266 271
267 // Сохранение формы смены пароля администоратора 272 // Сохранение формы смены пароля администоратора
268 public function profile_password_new(Request $request) { 273 public function profile_password_new(Request $request) {
269 274
270 $rules = [ 275 $rules = [
271 'old_password' => 'required|min:6', //|current_password:api', 276 'old_password' => 'required|min:6', //|current_password:api',
272 'password' => 'required|min:6|confirmed', 277 'password' => 'required|min:6|confirmed',
273 ]; 278 ];
274 $messages = [ 279 $messages = [
275 'required' => 'Укажите обязательное поле', 280 'required' => 'Укажите обязательное поле',
276 'confirmed' => 'Пароли не совпадают' 281 'confirmed' => 'Пароли не совпадают'
277 ]; 282 ];
278 283
279 $validator = Validator::make($request->all(), $rules, $messages); 284 $validator = Validator::make($request->all(), $rules, $messages);
280 285
281 if (! Hash::check($request->old_password, $request->user()->password)) { 286 if (! Hash::check($request->old_password, $request->user()->password)) {
282 return back()->withErrors([ 287 return back()->withErrors([
283 'old_password' => ['Неверный предыдущий пароль'] 288 'old_password' => ['Неверный предыдущий пароль']
284 ]); 289 ]);
285 } 290 }
286 291
287 if ($validator->fails()) { 292 if ($validator->fails()) {
288 return redirect()->route('admin.password') 293 return redirect()->route('admin.password')
289 ->withErrors($validator); 294 ->withErrors($validator);
290 } else { 295 } else {
291 $params = $request->all(); 296 $params = $request->all();
292 // устанавливаем новый пароль для пользователя 297 // устанавливаем новый пароль для пользователя
293 User::where('id', Auth::id()) 298 User::where('id', Auth::id())
294 ->update(['password' => Hash::make($request->password)]); 299 ->update(['password' => Hash::make($request->password)]);
295 session()->flash('success', 'Успешно изменен пароль!'); 300 session()->flash('success', 'Успешно изменен пароль!');
296 301
297 return redirect()->route('admin.password'); 302 return redirect()->route('admin.password');
298 } 303 }
299 } 304 }
300 305
301 // Страница конфигурация сайта - форма 306 // Страница конфигурация сайта - форма
302 public function config_form() { 307 public function config_form() {
303 $config = Company::find(1); 308 $config = Company::find(1);
304 return view('admin.config', compact('config')); 309 return view('admin.config', compact('config'));
305 } 310 }
306 311
307 // Страница конфигурация сайта - сохранение формы 312 // Страница конфигурация сайта - сохранение формы
308 public function store_config(CompanyRequest $request) { 313 public function store_config(CompanyRequest $request) {
309 $config = Company::find(1); 314 $config = Company::find(1);
310 315
311 $params = $request->all(); 316 $params = $request->all();
312 unset($params['logo']); 317 unset($params['logo']);
313 unset($params['image']); 318 unset($params['image']);
314 319
315 if ($request->has('logo')) { 320 if ($request->has('logo')) {
316 Storage::delete($config->logo); 321 Storage::delete($config->logo);
317 $params['logo'] = $request->file('logo')->store('config', 'public'); 322 $params['logo'] = $request->file('logo')->store('config', 'public');
318 } 323 }
319 324
320 if ($request->has('image')) { 325 if ($request->has('image')) {
321 Storage::delete($config->image); 326 Storage::delete($config->image);
322 $params['image'] = $request->file('image')->store('config', 'public'); 327 $params['image'] = $request->file('image')->store('config', 'public');
323 } 328 }
324 329
325 if (is_null($config)) { 330 if (is_null($config)) {
326 Company::create($params); 331 Company::create($params);
327 } else { 332 } else {
328 $config->update($params); 333 $config->update($params);
329 } 334 }
330 335
331 return redirect()->route('admin.config'); 336 return redirect()->route('admin.config');
332 } 337 }
333 338
334 339
335 } 340 }
336 341
1 <?php 1 <?php
2 2
3 namespace App\Models; 3 namespace App\Models;
4 4
5 // use Illuminate\Contracts\Auth\MustVerifyEmail; 5 // use Illuminate\Contracts\Auth\MustVerifyEmail;
6 use Illuminate\Database\Eloquent\Factories\HasFactory; 6 use Illuminate\Database\Eloquent\Factories\HasFactory;
7 use Illuminate\Foundation\Auth\User as Authenticatable; 7 use Illuminate\Foundation\Auth\User as Authenticatable;
8 use Illuminate\Notifications\Notifiable; 8 use Illuminate\Notifications\Notifiable;
9 use Laravel\Sanctum\HasApiTokens; 9 use Laravel\Sanctum\HasApiTokens;
10 10
11 class User extends Authenticatable 11 class User extends Authenticatable
12 { 12 {
13 use HasApiTokens, HasFactory, Notifiable; 13 use HasApiTokens, HasFactory, Notifiable;
14 14
15 /** 15 /**
16 * The attributes that are mass assignable. 16 * The attributes that are mass assignable.
17 * 17 *
18 * @var array<int, string> 18 * @var array<int, string>
19 */ 19 */
20 protected $fillable = [ 20 protected $fillable = [
21 'name', 21 'name',
22 'email', 22 'email',
23 'password', 23 'password',
24 'admin', 24 'admin',
25 'telephone', 25 'telephone',
26 'surname', 26 'surname',
27 'name_man', 27 'name_man',
28 'surname2', 28 'surname2',
29 'is_worker', 29 'is_worker',
30 'is_lookin', 30 'is_lookin',
31 'is_message', 31 'is_message',
32 'is_public', 32 'is_public',
33 'is_remove', 33 'is_remove',
34 'is_ban', 34 'is_ban',
35 'is_new', 35 'is_new',
36 'email_verified_at',
37 'created_at',
38 'updated_at'
36 ]; 39 ];
37 40
38 /** 41 /**
39 * The attributes that should be hidden for serialization. 42 * The attributes that should be hidden for serialization.
40 * 43 *
41 * @var array<int, string> 44 * @var array<int, string>
42 */ 45 */
43 protected $hidden = [ 46 protected $hidden = [
44 'password', 47 'password',
45 'remember_token', 48 'remember_token',
46 ]; 49 ];
47 50
48 /** 51 /**
49 * The attributes that should be cast. 52 * The attributes that should be cast.
50 * 53 *
51 * @var array<string, string> 54 * @var array<string, string>
52 */ 55 */
53 protected $casts = [ 56 protected $casts = [
54 'email_verified_at' => 'datetime', 57 'email_verified_at' => 'datetime',
55 ]; 58 ];
56 59
57 /* 60 /*
58 * Связь Пользователей системы с работодателями 61 * Связь Пользователей системы с работодателями
59 * users - employers 62 * users - employers
60 */ 63 */
61 public function employers() { 64 public function employers() {
62 return $this->hasMany(Employer::class, 'user_id'); 65 return $this->hasMany(Employer::class, 'user_id');
63 } 66 }
64 67
65 /* 68 /*
66 * Связь Пользователей системы с работниками 69 * Связь Пользователей системы с работниками
67 * users - workers 70 * users - workers
68 */ 71 */
69 public function workers() { 72 public function workers() {
70 return $this->hasMany(Worker::class, 'user_id'); 73 return $this->hasMany(Worker::class, 'user_id');
71 } 74 }
72 75
73 /* 76 /*
74 * Связь Модели Пользователей(Users) с Группами (Group_users) 77 * Связь Модели Пользователей(Users) с Группами (Group_users)
75 * users - group_users 78 * users - group_users
76 многие-ко-многим 79 многие-ко-многим
77 */ 80 */
78 public function ingroup() { 81 public function ingroup() {
79 return $this->belongsToMany(Group_user::class, 'group_works'); 82 return $this->belongsToMany(Group_user::class, 'group_works');
80 } 83 }
81 84
82 /* 85 /*
83 * Связь Пользователей системы с ссобщениями 86 * Связь Пользователей системы с ссобщениями
84 * users - messages 87 * users - messages
85 */ 88 */
86 public function messages() { 89 public function messages() {
87 return $this->hasMany(Message::class); 90 return $this->hasMany(Message::class);
88 } 91 }
89 92
90 /* 93 /*
91 * Связь Пользователей системы с статистика 94 * Связь Пользователей системы с статистика
92 * users - static_workers 95 * users - static_workers
93 */ 96 */
94 public function static_user() { 97 public function static_user() {
95 return $this->hasMany(Static_worker::class); 98 return $this->hasMany(Static_worker::class);
96 } 99 }
97 100
98 /* 101 /*
99 * Связь модели Юзеры (users) с моделью Группы пользователей (Group_works) 102 * Связь модели Юзеры (users) с моделью Группы пользователей (Group_works)
100 один-ко-многим 103 один-ко-многим
101 */ 104 */
102 public function peoples() { 105 public function peoples() {
103 return $this->hasMany(Group_works::class); 106 return $this->hasMany(Group_works::class);
104 } 107 }
105 108
106 public function scopeActive($query) { 109 public function scopeActive($query) {
107 return $query->where('is_remove', '=', '0'); 110 return $query->where('is_remove', '=', '0');
108 } 111 }
109 112
110 } 113 }
111 114
resources/views/admin/login.blade.php
1 @extends('layout.authorize', ['title' => 'Вход в административную панель']) 1 @extends('layout.authorize', ['title' => 'Вход в административную панель'])
2 2
3 @section('image') 3 @section('image')
4 <img 4 <img
5 aria-hidden="true" 5 aria-hidden="true"
6 class="object-cover w-full h-full dark:hidden" 6 class="object-cover w-full h-full dark:hidden"
7 src="{{ asset('assets/img/login-office.jpeg') }}" 7 src="{{ asset('assets/img/login-office.jpeg') }}"
8 alt="Office" 8 alt="Office"
9 /> 9 />
10 <img 10 <img
11 aria-hidden="true" 11 aria-hidden="true"
12 class="hidden object-cover w-full h-full dark:block" 12 class="hidden object-cover w-full h-full dark:block"
13 src="{{ asset('assets/img/login-office-dark.jpeg') }}" 13 src="{{ asset('assets/img/login-office-dark.jpeg') }}"
14 alt="Office" 14 alt="Office"
15 /> 15 />
16 @endsection 16 @endsection
17 17
18 @section('content') 18 @section('content')
19 <h1 class="mb-4 text-xl font-semibold text-gray-700 dark:text-gray-200"> 19 <h1 class="mb-4 text-xl font-semibold text-gray-700 dark:text-gray-200">
20 Авторизация 20 Авторизация в админке
21 </h1> 21 </h1>
22 22
23 <form method="post" action="{{ route('admin.auth') }}"> 23 <form method="post" action="{{ route('admin.auth') }}">
24 @csrf 24 @csrf
25 <label class="block text-sm"> 25 <label class="block text-sm">
26 <span class="text-gray-700 dark:text-gray-400">Email</span> 26 <span class="text-gray-700 dark:text-gray-400">Email</span>
27 <input name="email" class="block w-full mt-1 text-sm dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:text-gray-300 dark:focus:shadow-outline-gray form-input" 27 <input name="email" class="block w-full mt-1 text-sm dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:text-gray-300 dark:focus:shadow-outline-gray form-input"
28 placeholder="Email пользователя" value="{{ old('email') }}"/> 28 placeholder="Email пользователя" value="{{ old('email') }}"/>
29 </label> 29 </label>
30 <label class="block mt-4 text-sm"> 30 <label class="block mt-4 text-sm">
31 <span class="text-gray-700 dark:text-gray-400">Пароль</span> 31 <span class="text-gray-700 dark:text-gray-400">Пароль</span>
32 <input 32 <input
33 name="password" class="block w-full mt-1 text-sm dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:text-gray-300 dark:focus:shadow-outline-gray form-input" 33 name="password" class="block w-full mt-1 text-sm dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:text-gray-300 dark:focus:shadow-outline-gray form-input"
34 placeholder="Пароль" 34 placeholder="Пароль"
35 type="password" 35 type="password"
36 /> 36 />
37 </label> 37 </label>
38 <div class="form-group form-check"> 38 <div class="form-group form-check">
39 <input type="checkbox" class="form-check-input" name="remember" id="remember"> 39 <input type="checkbox" class="form-check-input" name="remember" id="remember">
40 <label class="form-check-label" for="remember"> 40 <label class="form-check-label" for="remember">
41 Запомнить меня 41 Запомнить меня
42 </label> 42 </label>
43 </div> 43 </div>
44 44
45 <!-- You should use a button here, as the anchor is only used for the example --> 45 <!-- You should use a button here, as the anchor is only used for the example -->
46 <button type="submit" 46 <button type="submit"
47 class="block w-full px-4 py-2 mt-4 text-sm font-medium leading-5 text-center text-white transition-colors duration-150 bg-purple-600 border border-transparent rounded-lg active:bg-purple-600 hover:bg-purple-700 focus:outline-none focus:shadow-outline-purple" 47 class="block w-full px-4 py-2 mt-4 text-sm font-medium leading-5 text-center text-white transition-colors duration-150 bg-purple-600 border border-transparent rounded-lg active:bg-purple-600 hover:bg-purple-700 focus:outline-none focus:shadow-outline-purple"
48 > 48 >
49 Войти 49 Войти
50 </button> 50 </button>
51 </form> 51 </form>
52 <hr class="my-8" /> 52 <hr class="my-8" />
53 <!-- 53 <!--
54 <button 54 <button
55 class="flex items-center justify-center w-full px-4 py-2 text-sm font-medium leading-5 text-white text-gray-700 transition-colors duration-150 border border-gray-300 rounded-lg dark:text-gray-400 active:bg-transparent hover:border-gray-500 focus:border-gray-500 active:text-gray-500 focus:outline-none focus:shadow-outline-gray" 55 class="flex items-center justify-center w-full px-4 py-2 text-sm font-medium leading-5 text-white text-gray-700 transition-colors duration-150 border border-gray-300 rounded-lg dark:text-gray-400 active:bg-transparent hover:border-gray-500 focus:border-gray-500 active:text-gray-500 focus:outline-none focus:shadow-outline-gray"
56 > 56 >
57 <svg 57 <svg
58 class="w-4 h-4 mr-2" 58 class="w-4 h-4 mr-2"
59 aria-hidden="true" 59 aria-hidden="true"
60 viewBox="0 0 24 24" 60 viewBox="0 0 24 24"
61 fill="currentColor" 61 fill="currentColor"
62 > 62 >
63 <path 63 <path
64 d="M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12" 64 d="M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"
65 /> 65 />
66 </svg> 66 </svg>
67 Github 67 Github
68 </button> 68 </button>
69 <button 69 <button
70 class="flex items-center justify-center w-full px-4 py-2 mt-4 text-sm font-medium leading-5 text-white text-gray-700 transition-colors duration-150 border border-gray-300 rounded-lg dark:text-gray-400 active:bg-transparent hover:border-gray-500 focus:border-gray-500 active:text-gray-500 focus:outline-none focus:shadow-outline-gray" 70 class="flex items-center justify-center w-full px-4 py-2 mt-4 text-sm font-medium leading-5 text-white text-gray-700 transition-colors duration-150 border border-gray-300 rounded-lg dark:text-gray-400 active:bg-transparent hover:border-gray-500 focus:border-gray-500 active:text-gray-500 focus:outline-none focus:shadow-outline-gray"
71 > 71 >
72 <svg 72 <svg
73 class="w-4 h-4 mr-2" 73 class="w-4 h-4 mr-2"
74 aria-hidden="true" 74 aria-hidden="true"
75 viewBox="0 0 24 24" 75 viewBox="0 0 24 24"
76 fill="currentColor" 76 fill="currentColor"
77 > 77 >
78 <path 78 <path
79 d="M23.954 4.569c-.885.389-1.83.654-2.825.775 1.014-.611 1.794-1.574 2.163-2.723-.951.555-2.005.959-3.127 1.184-.896-.959-2.173-1.559-3.591-1.559-2.717 0-4.92 2.203-4.92 4.917 0 .39.045.765.127 1.124C7.691 8.094 4.066 6.13 1.64 3.161c-.427.722-.666 1.561-.666 2.475 0 1.71.87 3.213 2.188 4.096-.807-.026-1.566-.248-2.228-.616v.061c0 2.385 1.693 4.374 3.946 4.827-.413.111-.849.171-1.296.171-.314 0-.615-.03-.916-.086.631 1.953 2.445 3.377 4.604 3.417-1.68 1.319-3.809 2.105-6.102 2.105-.39 0-.779-.023-1.17-.067 2.189 1.394 4.768 2.209 7.557 2.209 9.054 0 13.999-7.496 13.999-13.986 0-.209 0-.42-.015-.63.961-.689 1.8-1.56 2.46-2.548l-.047-.02z" 79 d="M23.954 4.569c-.885.389-1.83.654-2.825.775 1.014-.611 1.794-1.574 2.163-2.723-.951.555-2.005.959-3.127 1.184-.896-.959-2.173-1.559-3.591-1.559-2.717 0-4.92 2.203-4.92 4.917 0 .39.045.765.127 1.124C7.691 8.094 4.066 6.13 1.64 3.161c-.427.722-.666 1.561-.666 2.475 0 1.71.87 3.213 2.188 4.096-.807-.026-1.566-.248-2.228-.616v.061c0 2.385 1.693 4.374 3.946 4.827-.413.111-.849.171-1.296.171-.314 0-.615-.03-.916-.086.631 1.953 2.445 3.377 4.604 3.417-1.68 1.319-3.809 2.105-6.102 2.105-.39 0-.779-.023-1.17-.067 2.189 1.394 4.768 2.209 7.557 2.209 9.054 0 13.999-7.496 13.999-13.986 0-.209 0-.42-.015-.63.961-.689 1.8-1.56 2.46-2.548l-.047-.02z"
80 /> 80 />
81 </svg> 81 </svg>
82 Twitter 82 Twitter
83 </button> 83 </button>
84 --> 84 -->
85 <!-- <p class="mt-4"> 85 <!-- <p class="mt-4">
86 <a 86 <a
87 class="text-sm font-medium text-purple-600 dark:text-purple-400 hover:underline" 87 class="text-sm font-medium text-purple-600 dark:text-purple-400 hover:underline"
88 href="./forgot-password.html" 88 href="./forgot-password.html"
89 > 89 >
90 Forgot your password? 90 Forgot your password?
91 </a> 91 </a>
92 </p>--> 92 </p>-->
93 <p class="mt-1"> 93 <p class="mt-1">
94 <a 94 <a
95 class="text-sm font-medium text-purple-600 dark:text-purple-400 hover:underline" 95 class="text-sm font-medium text-purple-600 dark:text-purple-400 hover:underline"
96 href="{{ route('admin.register') }}" 96 href="{{ route('admin.register') }}"
97 > 97 >
98 Создание аккаунта 98 Создание аккаунта
99 </a> 99 </a>
100 </p> 100 </p>
101 <p class="mt-1">
102 <a
103 class="text-sm font-medium text-purple-600 dark:text-purple-400 hover:underline"
104 href="{{ route('index') }}"
105 >
106 Главная страница
107 </a>
108 </p>
101 @endsection 109 @endsection
102 110
resources/views/admin/register.blade.php
1 @extends('layout.authorize', ['title' => 'Регистрация в административной панели']) 1 @extends('layout.authorize', ['title' => 'Регистрация в административной панели'])
2 2
3 @section('image') 3 @section('image')
4 <img 4 <img
5 aria-hidden="true" 5 aria-hidden="true"
6 class="object-cover w-full h-full dark:hidden" 6 class="object-cover w-full h-full dark:hidden"
7 src="{{ asset('assets/img/create-account-office.jpeg') }}" 7 src="{{ asset('assets/img/create-account-office.jpeg') }}"
8 alt="Office" 8 alt="Office"
9 /> 9 />
10 <img 10 <img
11 aria-hidden="true" 11 aria-hidden="true"
12 class="hidden object-cover w-full h-full dark:block" 12 class="hidden object-cover w-full h-full dark:block"
13 src="{{ asset('assets/img/create-account-office-dark.jpeg') }}" 13 src="{{ asset('assets/img/create-account-office-dark.jpeg') }}"
14 alt="Office" 14 alt="Office"
15 /> 15 />
16 @endsection 16 @endsection
17 17
18 @section('content') 18 @section('content')
19 <h1 19 <h1
20 class="mb-4 text-xl font-semibold text-gray-700 dark:text-gray-200" 20 class="mb-4 text-xl font-semibold text-gray-700 dark:text-gray-200"
21 > 21 >
22 Создание аккаунта 22 Создание аккаунта администратора
23 </h1> 23 </h1>
24 <form method="POST" action="{{ route('admin.create') }}"> 24 <form method="POST" action="{{ route('admin.create') }}">
25 @csrf 25 @csrf
26 <label class="block text-sm"> 26 <label class="block text-sm">
27 <span class="text-gray-700 dark:text-gray-400">Имя</span> 27 <span class="text-gray-700 dark:text-gray-400">Имя</span>
28 <input id="name" name="name" 28 <input id="name" name="name"
29 class="block w-full mt-1 text-sm dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:text-gray-300 dark:focus:shadow-outline-gray form-input" 29 class="block w-full mt-1 text-sm dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:text-gray-300 dark:focus:shadow-outline-gray form-input"
30 placeholder="Введите имя" value="{{ old('name') }}" 30 placeholder="Введите имя" value="{{ old('name') }}"
31 /> 31 />
32 @error('name') 32 @error('name')
33 <span class="invalid-feedback" role="alert"> 33 <span class="invalid-feedback" role="alert">
34 <strong>{{ $message }}</strong> 34 <strong>{{ $message }}</strong>
35 </span> 35 </span>
36 @enderror 36 @enderror
37 </label> 37 </label>
38 38
39 <label class="block text-sm"> 39 <label class="block text-sm">
40 <span class="text-gray-700 dark:text-gray-400">Email</span> 40 <span class="text-gray-700 dark:text-gray-400">Email</span>
41 <input id="email" name="email" type="email" 41 <input id="email" name="email" type="email"
42 class="block w-full mt-1 text-sm dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:text-gray-300 dark:focus:shadow-outline-gray form-input" 42 class="block w-full mt-1 text-sm dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:text-gray-300 dark:focus:shadow-outline-gray form-input"
43 placeholder="Введите email" value="{{ old('email') }}" autocomplete="email" 43 placeholder="Введите email" value="{{ old('email') }}" autocomplete="email"
44 /> 44 />
45 @error('email') 45 @error('email')
46 <span class="invalid-feedback" role="alert"> 46 <span class="invalid-feedback" role="alert">
47 <strong>{{ $message }}</strong> 47 <strong>{{ $message }}</strong>
48 </span> 48 </span>
49 @enderror 49 @enderror
50 </label> 50 </label>
51 51
52 <label class="block mt-4 text-sm"> 52 <label class="block mt-4 text-sm">
53 <span class="text-gray-700 dark:text-gray-400">Пароль</span> 53 <span class="text-gray-700 dark:text-gray-400">Пароль</span>
54 <input id="password" name="password" 54 <input id="password" name="password"
55 class="block w-full mt-1 text-sm dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:text-gray-300 dark:focus:shadow-outline-gray form-input" 55 class="block w-full mt-1 text-sm dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:text-gray-300 dark:focus:shadow-outline-gray form-input"
56 placeholder="Пароль" 56 placeholder="Пароль"
57 type="password" 57 type="password"
58 /> 58 />
59 @error('password') 59 @error('password')
60 <span class="invalid-feedback" role="alert"> 60 <span class="invalid-feedback" role="alert">
61 <strong>{{ $message }}</strong> 61 <strong>{{ $message }}</strong>
62 </span> 62 </span>
63 @enderror 63 @enderror
64 </label> 64 </label>
65 65
66 <label class="block mt-4 text-sm"> 66 <label class="block mt-4 text-sm">
67 <span class="text-gray-700 dark:text-gray-400"> 67 <span class="text-gray-700 dark:text-gray-400">
68 Подтверждение пароля 68 Подтверждение пароля
69 </span> 69 </span>
70 <input id="password-confirm" name="password_confirmation" 70 <input id="password-confirm" name="password_confirmation"
71 class="block w-full mt-1 text-sm dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:text-gray-300 dark:focus:shadow-outline-gray form-input" 71 class="block w-full mt-1 text-sm dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:text-gray-300 dark:focus:shadow-outline-gray form-input"
72 placeholder="Подтверждение пароля" 72 placeholder="Подтверждение пароля"
73 type="password" 73 type="password"
74 /> 74 />
75 </label> 75 </label>
76 76
77 <div class="flex mt-6 text-sm"> 77 <div class="flex mt-6 text-sm">
78 <label class="flex items-center dark:text-gray-400"> 78 <label class="flex items-center dark:text-gray-400">
79 <input 79 <input
80 type="checkbox" 80 type="checkbox"
81 class="text-purple-600 form-checkbox focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:focus:shadow-outline-gray" 81 class="text-purple-600 form-checkbox focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:focus:shadow-outline-gray"
82 /> 82 />
83 <span class="ml-2"> 83 <span class="ml-2">
84 Я принимаю условия 84 Я принимаю условия
85 <span class="underline">политики безопасности</span> 85 <span class="underline">политики безопасности</span>
86 </span> 86 </span>
87 </label> 87 </label>
88 </div> 88 </div>
89 89
90 <!-- You should use a button here, as the anchor is only used for the example --> 90 <!-- You should use a button here, as the anchor is only used for the example -->
91 <button 91 <button
92 class="block w-full px-4 py-2 mt-4 text-sm font-medium leading-5 text-center text-white transition-colors duration-150 bg-purple-600 border border-transparent rounded-lg active:bg-purple-600 hover:bg-purple-700 focus:outline-none focus:shadow-outline-purple" 92 class="block w-full px-4 py-2 mt-4 text-sm font-medium leading-5 text-center text-white transition-colors duration-150 bg-purple-600 border border-transparent rounded-lg active:bg-purple-600 hover:bg-purple-700 focus:outline-none focus:shadow-outline-purple"
93 type="submit" 93 type="submit"
94 > 94 >
95 Создать пользователя 95 Создать пользователя
96 </button> 96 </button>
97 </form> 97 </form>
98 <hr class="my-8" /> 98 <hr class="my-8" />
99 99
100 <!--<button 100 <!--<button
101 class="flex items-center justify-center w-full px-4 py-2 text-sm font-medium leading-5 text-white text-gray-700 transition-colors duration-150 border border-gray-300 rounded-lg dark:text-gray-400 active:bg-transparent hover:border-gray-500 focus:border-gray-500 active:text-gray-500 focus:outline-none focus:shadow-outline-gray" 101 class="flex items-center justify-center w-full px-4 py-2 text-sm font-medium leading-5 text-white text-gray-700 transition-colors duration-150 border border-gray-300 rounded-lg dark:text-gray-400 active:bg-transparent hover:border-gray-500 focus:border-gray-500 active:text-gray-500 focus:outline-none focus:shadow-outline-gray"
102 > 102 >
103 <svg 103 <svg
104 class="w-4 h-4 mr-2" 104 class="w-4 h-4 mr-2"
105 aria-hidden="true" 105 aria-hidden="true"
106 viewBox="0 0 24 24" 106 viewBox="0 0 24 24"
107 fill="currentColor" 107 fill="currentColor"
108 > 108 >
109 <path 109 <path
110 d="M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12" 110 d="M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"
111 /> 111 />
112 </svg> 112 </svg>
113 Github 113 Github
114 </button> 114 </button>
115 <button 115 <button
116 class="flex items-center justify-center w-full px-4 py-2 mt-4 text-sm font-medium leading-5 text-white text-gray-700 transition-colors duration-150 border border-gray-300 rounded-lg dark:text-gray-400 active:bg-transparent hover:border-gray-500 focus:border-gray-500 active:text-gray-500 focus:outline-none focus:shadow-outline-gray" 116 class="flex items-center justify-center w-full px-4 py-2 mt-4 text-sm font-medium leading-5 text-white text-gray-700 transition-colors duration-150 border border-gray-300 rounded-lg dark:text-gray-400 active:bg-transparent hover:border-gray-500 focus:border-gray-500 active:text-gray-500 focus:outline-none focus:shadow-outline-gray"
117 > 117 >
118 <svg 118 <svg
119 class="w-4 h-4 mr-2" 119 class="w-4 h-4 mr-2"
120 aria-hidden="true" 120 aria-hidden="true"
121 viewBox="0 0 24 24" 121 viewBox="0 0 24 24"
122 fill="currentColor" 122 fill="currentColor"
123 > 123 >
124 <path 124 <path
125 d="M23.954 4.569c-.885.389-1.83.654-2.825.775 1.014-.611 1.794-1.574 2.163-2.723-.951.555-2.005.959-3.127 1.184-.896-.959-2.173-1.559-3.591-1.559-2.717 0-4.92 2.203-4.92 4.917 0 .39.045.765.127 1.124C7.691 8.094 4.066 6.13 1.64 3.161c-.427.722-.666 1.561-.666 2.475 0 1.71.87 3.213 2.188 4.096-.807-.026-1.566-.248-2.228-.616v.061c0 2.385 1.693 4.374 3.946 4.827-.413.111-.849.171-1.296.171-.314 0-.615-.03-.916-.086.631 1.953 2.445 3.377 4.604 3.417-1.68 1.319-3.809 2.105-6.102 2.105-.39 0-.779-.023-1.17-.067 2.189 1.394 4.768 2.209 7.557 2.209 9.054 0 13.999-7.496 13.999-13.986 0-.209 0-.42-.015-.63.961-.689 1.8-1.56 2.46-2.548l-.047-.02z" 125 d="M23.954 4.569c-.885.389-1.83.654-2.825.775 1.014-.611 1.794-1.574 2.163-2.723-.951.555-2.005.959-3.127 1.184-.896-.959-2.173-1.559-3.591-1.559-2.717 0-4.92 2.203-4.92 4.917 0 .39.045.765.127 1.124C7.691 8.094 4.066 6.13 1.64 3.161c-.427.722-.666 1.561-.666 2.475 0 1.71.87 3.213 2.188 4.096-.807-.026-1.566-.248-2.228-.616v.061c0 2.385 1.693 4.374 3.946 4.827-.413.111-.849.171-1.296.171-.314 0-.615-.03-.916-.086.631 1.953 2.445 3.377 4.604 3.417-1.68 1.319-3.809 2.105-6.102 2.105-.39 0-.779-.023-1.17-.067 2.189 1.394 4.768 2.209 7.557 2.209 9.054 0 13.999-7.496 13.999-13.986 0-.209 0-.42-.015-.63.961-.689 1.8-1.56 2.46-2.548l-.047-.02z"
126 /> 126 />
127 </svg> 127 </svg>
128 Twitter 128 Twitter
129 </button>--> 129 </button>-->
130 130
131 <p class="mt-4"> 131 <p class="mt-4">
132 <a 132 <a
133 class="text-sm font-medium text-purple-600 dark:text-purple-400 hover:underline" 133 class="text-sm font-medium text-purple-600 dark:text-purple-400 hover:underline"
134 href="./login.html" 134 href="{{ route('admin.login') }}"
135 > 135 >
136 Already have an account? Login 136 Авторизация в системе
137 </a>
138 </p>
139 <p class="mt-1">
140 <a
141 class="text-sm font-medium text-purple-600 dark:text-purple-400 hover:underline"
142 href="{{ route('index') }}"
143 >
144 Главная страница
137 </a> 145 </a>
138 </p> 146 </p>
139 @endsection 147 @endsection
140 148
resources/views/layouts/app.blade.php
1 <!doctype html> 1 <!doctype html>
2 <html lang="{{ str_replace('_', '-', app()->getLocale()) }}"> 2 <html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
3 <head> 3 <head>
4 <meta charset="utf-8"> 4 <meta charset="utf-8">
5 <meta name="viewport" content="width=device-width, initial-scale=1"> 5 <meta name="viewport" content="width=device-width, initial-scale=1">
6 6
7 <!-- CSRF Token --> 7 <!-- CSRF Token -->
8 <meta name="csrf-token" content="{{ csrf_token() }}"> 8 <meta name="csrf-token" content="{{ csrf_token() }}">
9 9
10 <title>{{ $title }}</title> 10 <title>{{ $title }}</title>
11 </head> 11 </head>
12 <body> 12 <body>
13 <div> 13 <div>
14 <nav class="navbar navbar-expand-md navbar-light bg-white shadow-sm"> 14 <nav class="navbar navbar-expand-md navbar-light bg-white shadow-sm">
15 <div class="container"> 15 <div class="container">
16 <a class="navbar-brand" href="{{ url('/') }}"> 16 <a class="navbar-brand" href="{{ url('/') }}">
17 {{ config('app.name', 'Laravel') }} 17 {{ config('app.name', 'Laravel') }}
18 </a> 18 </a>
19 <!--<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="{{ __('Toggle navigation') }}"> 19 <!--<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="{{ __('Toggle navigation') }}">
20 <span class="navbar-toggler-icon"></span> 20 <span class="navbar-toggler-icon"></span>
21 </button>--> 21 </button>-->
22 22
23 <div class="collapse navbar-collapse" id="navbarSupportedContent"> 23 <div class="collapse navbar-collapse" id="navbarSupportedContent">
24 <!-- Left Side Of Navbar --> 24 <!-- Left Side Of Navbar -->
25 <ul class="navbar-nav me-auto"> 25 <ul class="navbar-nav me-auto">
26 26
27 </ul> 27 </ul>
28 28
29 <!-- Right Side Of Navbar --> 29 <!-- Right Side Of Navbar -->
30 <ul class="navbar-nav ms-auto"> 30 <ul class="navbar-nav ms-auto">
31 <!-- Authentication Links --> 31 <!-- Authentication Links -->
32 @guest 32 @guest
33 @if (Route::has('login')) 33 @if (Route::has('login'))
34 <li class="nav-item"> 34 <li class="nav-item">
35 <a class="nav-link" href="{{ route('login') }}">{{ __('Login') }}</a> 35 <a class="nav-link" href="{{ route('login') }}">{{ __('Login') }}</a>
36 </li> 36 </li>
37 @endif 37 @endif
38 38
39 @if (Route::has('register')) 39 @if (Route::has('register'))
40 <li class="nav-item"> 40 <li class="nav-item">
41 <a class="nav-link" href="{{ route('register') }}">{{ __('Register') }}</a> 41 <a class="nav-link" href="{{ route('register') }}">{{ __('Register') }}</a>
42 </li> 42 </li>
43 @endif 43 @endif
44 @else 44 @else
45 <li class="nav-item dropdown"> 45 <li class="nav-item dropdown">
46 <a id="navbarDropdown" class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false" v-pre> 46 <a id="navbarDropdown" class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false" v-pre>
47 {{ Auth::user()->name }} 47 {{ Auth::user()->name }}
48 </a> 48 </a><br>
49
50 @if (Auth::user()->admin)
51 <a href="{{ route('admin.index') }}">Личный кабинет пользователя</a><br>
52 @endif
49 53
50 <div class="dropdown-menu dropdown-menu-end" aria-labelledby="navbarDropdown"> 54 <div class="dropdown-menu dropdown-menu-end" aria-labelledby="navbarDropdown">
51 <a class="dropdown-item" href="{{ route('logout') }}" 55 <a class="dropdown-item" href="{{ route('logout') }}"
52 onclick="event.preventDefault(); 56 onclick="event.preventDefault();
53 document.getElementById('logout-form').submit();"> 57 document.getElementById('logout-form').submit();">
54 {{ __('Logout') }} 58 {{ __('Logout') }}
55 </a> 59 </a>
56 60
57 <form id="logout-form" action="{{ route('logout') }}" method="POST" class="d-none"> 61 <form id="logout-form" action="{{ route('logout') }}" method="POST" class="d-none">
58 @csrf 62 @csrf
59 </form> 63 </form>
60 </div> 64 </div>
61 </li> 65 </li>
62 @endguest 66 @endguest
63 </ul> 67 </ul>
64 </div> 68 </div>
65 </div> 69 </div>
66 </nav> 70 </nav>
67 71
68 <main class="py-4"> 72 <main class="py-4">
69 @if ($message = Session::get('success')) 73 @if ($message = Session::get('success'))
70 <div class="alert alert-success alert-dismissible mt-0" role="alert"> 74 <div class="alert alert-success alert-dismissible mt-0" role="alert">
71 <button type="button" class="close" data-dismiss="alert" aria-label="Закрыть"> 75 <button type="button" class="close" data-dismiss="alert" aria-label="Закрыть">
72 <span aria-hidden="true">&times;</span> 76 <span aria-hidden="true">&times;</span>
73 </button> 77 </button>
74 {{ $message }} 78 {{ $message }}
75 </div> 79 </div>
76 @endif 80 @endif
77 81
78 @if ($errors->any()) 82 @if ($errors->any())
79 <div class="alert alert-danger alert-dismissible mt-4" role="alert"> 83 <div class="alert alert-danger alert-dismissible mt-4" role="alert">
80 <button type="button" class="close" data-dismiss="alert" aria-label="Закрыть"> 84 <button type="button" class="close" data-dismiss="alert" aria-label="Закрыть">
81 <span aria-hidden="true">&times;</span> 85 <span aria-hidden="true">&times;</span>
82 </button> 86 </button>
83 <ul class="mb-0"> 87 <ul class="mb-0">
84 @foreach ($errors->all() as $error) 88 @foreach ($errors->all() as $error)
85 <li>{{ $error }}</li> 89 <li>{{ $error }}</li>
86 @endforeach 90 @endforeach
87 </ul> 91 </ul>
88 </div> 92 </div>
89 @endif 93 @endif
90 94
91 @yield('content') 95 @yield('content')
92 </main> 96 </main>
93 </div> 97 </div>
94 </body> 98 </body>
95 </html> 99 </html>
96 100