Commit c84db52439fd511a8a13a49ce2325b815f00dc7f

Authored by Андрей Ларионов
1 parent 7c1e052482

Форма редактирования работника и работодателя

Showing 15 changed files with 672 additions and 9 deletions Side-by-side Diff

app/Http/Controllers/Admin/AdminController.php
... ... @@ -162,6 +162,55 @@ class AdminController extends Controller
162 162 }
163 163 }
164 164  
  165 + //Страница профиль пользователя - форма
  166 + public function profile_user(User $user) {
  167 + $visible = false;
  168 + if($user->is_worker) {
  169 + $caption = "Карточка работника";
  170 + if (isset($user->workers[0]->id)) {
  171 + $link = route('admin.worker-profile', ['worker' => $user->workers[0]->id]);
  172 + $visible = true;
  173 + } else {
  174 + $link = "";
  175 + }
  176 +
  177 + } else {
  178 + $caption = "Карточка работодателя";
  179 + if (isset($user->employers[0]->id)) {
  180 +
  181 + $link = route('admin.employer-profile', ['employer' => $user->employers[0]->id]);
  182 + $visible = true;
  183 + } else {
  184 + $link = "";
  185 + }
  186 + }
  187 +
  188 + return view('admin.users.profile', compact('user', 'visible', 'link', 'caption'));
  189 + }
  190 +
  191 + //Страница профиль пользователя - сохранение формы
  192 + public function store_profile_user(User $user, Request $request) {
  193 + $rules = [
  194 + 'name' => 'required|min:3',
  195 + ];
  196 + $messages = [
  197 + 'required' => 'Укажите обязательное поле',
  198 + 'email' => 'Это поле должно быть определено, как Email'
  199 + ];
  200 + $validator = Validator::make($request->all(), $rules, $messages);
  201 +
  202 + if ($validator->fails()) {
  203 + return redirect()->route('admin.user-profile', ['user' => $user->id])
  204 + ->withErrors($validator);
  205 + } else {
  206 + $user->update($request->all());
  207 + return redirect()->route('admin.user-profile', ['user' => $user->id])
  208 + ->with('success', 'Данные были успешно сохранены');
  209 + }
  210 + return redirect()->route('admin.user-profile', ['user' => $user->id]);
  211 + }
  212 +
  213 + // Страница профиль админа - форма
165 214 public function profile() {
166 215 $id = Auth::user()->id;
167 216 $user = User::find($id);
... ... @@ -169,18 +218,82 @@ class AdminController extends Controller
169 218 return view('admin.profile', compact('user'));
170 219 }
171 220  
  221 + // Страница профиль админа - сохранение формы
172 222 public function store_profile(Request $request) {
173 223 $id = Auth::user()->id;
174 224 $user = User::find($id);
175 225  
  226 + $rules = [
  227 + 'name' => 'required|min:3',
  228 + 'email' => 'required|email|min:3',
  229 + ];
  230 + $messages = [
  231 + 'required' => 'Укажите обязательное поле',
  232 + 'email' => 'Это поле должно быть определено, как Email'
  233 + ];
  234 + $validator = Validator::make($request->all(), $rules, $messages);
  235 +
  236 + if ($validator->fails()) {
  237 + return redirect()->route('admin.profile')
  238 + ->withErrors($validator);
  239 + } else {
  240 + $user->update($request->all());
  241 + return redirect()->route('admin.profile')
  242 + ->with('success', 'Данные были успешно сохранены');
  243 + }
176 244 return redirect()->route('admin.profile');
177 245 }
178 246  
  247 + // Форма смены пароля администоратора
  248 + public function profile_password() {
  249 + $id = Auth::user()->id;
  250 + $user = User::find($id);
  251 + $username = $user->name;
  252 +
  253 + return view('admin.password', compact('username'));
  254 + }
  255 +
  256 + // Сохранение формы смены пароля администоратора
  257 + public function profile_password_new(Request $request) {
  258 +
  259 + $rules = [
  260 + 'old_password' => 'required|min:6', //|current_password:api',
  261 + 'password' => 'required|min:6|confirmed',
  262 + ];
  263 + $messages = [
  264 + 'required' => 'Укажите обязательное поле',
  265 + 'confirmed' => 'Пароли не совпадают'
  266 + ];
  267 +
  268 + $validator = Validator::make($request->all(), $rules, $messages);
  269 +
  270 + if (! Hash::check($request->old_password, $request->user()->password)) {
  271 + return back()->withErrors([
  272 + 'old_password' => ['Неверный предыдущий пароль']
  273 + ]);
  274 + }
  275 +
  276 + if ($validator->fails()) {
  277 + return redirect()->route('admin.password')
  278 + ->withErrors($validator);
  279 + } else {
  280 + $params = $request->all();
  281 + // устанавливаем новый пароль для пользователя
  282 + User::where('id', Auth::id())
  283 + ->update(['password' => Hash::make($request->password)]);
  284 + session()->flash('success', 'Успешно изменен пароль!');
  285 +
  286 + return redirect()->route('admin.password');
  287 + }
  288 + }
  289 +
  290 + // Страница конфигурация сайта - форма
179 291 public function config_form() {
180 292 $config = Company::find(1);
181 293 return view('admin.config', compact('config'));
182 294 }
183 295  
  296 + // Страница конфигурация сайта - сохранение формы
184 297 public function store_config(CompanyRequest $request) {
185 298 $config = Company::find(1);
186 299  
app/Http/Controllers/Admin/EmployersController.php
... ... @@ -3,6 +3,7 @@
3 3 namespace App\Http\Controllers\Admin;
4 4  
5 5 use App\Http\Controllers\Controller;
  6 +use App\Models\Employer;
6 7 use App\Models\User;
7 8 use Illuminate\Http\Request;
8 9  
... ... @@ -22,4 +23,8 @@ class EmployersController extends Controller
22 23 return view('admin.employer.index', compact('users'));
23 24 }
24 25 }
  26 +
  27 + public function form_update_employer(Employer $employer) {
  28 + return view('admin.employer.edit', compact('employer'));
  29 + }
25 30 }
app/Http/Controllers/Admin/WorkersController.php
... ... @@ -4,6 +4,7 @@ namespace App\Http\Controllers\Admin;
4 4  
5 5 use App\Http\Controllers\Controller;
6 6 use App\Models\User;
  7 +use App\Models\Worker;
7 8 use Illuminate\Http\Request;
8 9  
9 10 class WorkersController extends Controller
... ... @@ -23,4 +24,8 @@ class WorkersController extends Controller
23 24 return view('admin.worker.index', compact('users'));
24 25 }
25 26 }
  27 +
  28 + public function form_update_worker(Worker $worker) {
  29 + return view('admin.worker.edit');
  30 + }
26 31 }
... ... @@ -59,7 +59,7 @@ class User extends Authenticatable
59 59 * users - employers
60 60 */
61 61 public function employers() {
62   - return $this->hasMany(Employer::class);
  62 + return $this->hasMany(Employer::class, 'user_id');
63 63 }
64 64  
65 65 /*
... ... @@ -67,7 +67,7 @@ class User extends Authenticatable
67 67 * users - workers
68 68 */
69 69 public function workers() {
70   - return $this->hasMany(Worker::class);
  70 + return $this->hasMany(Worker::class, 'user_id');
71 71 }
72 72  
73 73 /*
resources/views/admin/employer/edit.blade.php
... ... @@ -0,0 +1,320 @@
  1 +@extends('layout.admin', ['title' => 'Админка - Редактирование работодателя'])
  2 +
  3 +@section('content')
  4 + <h4 class="mb-4 text-lg font-semibold text-gray-600 dark:text-gray-300">
  5 + Работодатель-пользователь: "{{$employer->users->name_man}} ({{$employer->user_id}})"
  6 + </h4>
  7 + <form method="POST" action="">
  8 + @csrf
  9 + <div class="px-4 py-3 mb-8 bg-white rounded-lg shadow-md dark:bg-gray-800">
  10 + <label class="block text-sm">
  11 + <span class="text-gray-700 dark:text-gray-400">Имя компании</span>
  12 + <input name="name_company" id="name_company"
  13 + 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"
  14 + placeholder="Имя компании" value="{{ old('name_company') ?? $employer->name_company ?? '' }}"
  15 + />
  16 + @error('name_company')
  17 + <span class="text-xs text-red-600 dark:text-red-400">
  18 + {{ $message }}
  19 + </span>
  20 + @enderror
  21 + </label><br>
  22 +
  23 + <label class="block text-sm">
  24 + <span class="text-gray-700 dark:text-gray-400">Email</span>
  25 + <input name="email" id="email"
  26 + 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 + placeholder="Почта" value="{{ old('email') ?? $employer->email ?? '' }}"
  28 + />
  29 + @error('email')
  30 + <span class="text-xs text-red-600 dark:text-red-400">
  31 + {{ $message }}
  32 + </span>
  33 + @enderror
  34 + </label><br>
  35 +
  36 + <label class="block text-sm">
  37 + <span class="text-gray-700 dark:text-gray-400">Телефон</span>
  38 + <input name="telephone" id="telephone"
  39 + 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"
  40 + placeholder="Телефон" value="{{ old('telephone') ?? $employer->telephone ?? '' }}"
  41 + />
  42 + @error('telephone')
  43 + <span class="text-xs text-red-600 dark:text-red-400">
  44 + {{ $message }}
  45 + </span>
  46 + @enderror
  47 + </label><br>
  48 +
  49 + <label class="block text-sm">
  50 + <span class="text-gray-700 dark:text-gray-400">Адрес</span>
  51 + <input name="address" id="address"
  52 + 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"
  53 + placeholder="Адрес" value="{{ old('address') ?? $employer->address ?? '' }}"
  54 + />
  55 + @error('address')
  56 + <span class="text-xs text-red-600 dark:text-red-400">
  57 + {{ $message }}
  58 + </span>
  59 + @enderror
  60 + </label><br>
  61 +
  62 + <label class="block text-sm">
  63 + <span class="text-gray-700 dark:text-gray-400">Сайт</span>
  64 + <input name="site" id="site"
  65 + 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"
  66 + placeholder="Сайт" value="{{ old('site') ?? $employer->site ?? '' }}"
  67 + />
  68 + @error('site')
  69 + <span class="text-xs text-red-600 dark:text-red-400">
  70 + {{ $message }}
  71 + </span>
  72 + @enderror
  73 + </label><br>
  74 +
  75 + <label class="block text-sm">
  76 + <span class="text-gray-700 dark:text-gray-400">Лого</span>
  77 + <input name="logo" id="logo"
  78 + 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"
  79 + placeholder="Лого" value=""
  80 + />
  81 + @error('logo')
  82 + <span class="text-xs text-red-600 dark:text-red-400">
  83 + {{ $message }}
  84 + </span>
  85 + @enderror
  86 + </label><br>
  87 +
  88 + <div class="flex flex-col flex-wrap mb-4 space-y-4 md:flex-row md:items-end md:space-x-4">
  89 + <div>
  90 + <button type="submit" class="px-3 py-1 text-sm font-medium leading-5 text-white transition-colors duration-150 bg-purple-600 border border-transparent rounded-md active:bg-purple-600 hover:bg-purple-700 focus:outline-none focus:shadow-outline-purple">
  91 + Сохранить
  92 + </button>
  93 + </div>
  94 + </div>
  95 + </div>
  96 + </form>
  97 + <!--
  98 + <label class="block mt-4 text-sm">
  99 + <span class="text-gray-700 dark:text-gray-400">
  100 + Requested Limit
  101 + </span>
  102 + <select
  103 + class="block w-full mt-1 text-sm dark:text-gray-300 dark:border-gray-600 dark:bg-gray-700 form-select focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:focus:shadow-outline-gray"
  104 + >
  105 + <option>$1,000</option>
  106 + <option>$5,000</option>
  107 + <option>$10,000</option>
  108 + <option>$25,000</option>
  109 + </select>
  110 + </label>
  111 +
  112 + <label class="block mt-4 text-sm">
  113 + <span class="text-gray-700 dark:text-gray-400">
  114 + Multiselect
  115 + </span>
  116 + <select
  117 + class="block w-full mt-1 text-sm dark:text-gray-300 dark:border-gray-600 dark:bg-gray-700 form-multiselect focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:focus:shadow-outline-gray"
  118 + multiple
  119 + >
  120 + <option>Option 1</option>
  121 + <option>Option 2</option>
  122 + <option>Option 3</option>
  123 + <option>Option 4</option>
  124 + <option>Option 5</option>
  125 + </select>
  126 + </label>
  127 +
  128 + <label class="block mt-4 text-sm">
  129 + <span class="text-gray-700 dark:text-gray-400">Message</span>
  130 + <textarea
  131 + class="block w-full mt-1 text-sm dark:text-gray-300 dark:border-gray-600 dark:bg-gray-700 form-textarea focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:focus:shadow-outline-gray"
  132 + rows="3"
  133 + placeholder="Enter some long form content."
  134 + ></textarea>
  135 + </label>
  136 +
  137 + <div class="flex mt-6 text-sm">
  138 + <label class="flex items-center dark:text-gray-400">
  139 + <input
  140 + type="checkbox"
  141 + class="text-purple-600 form-checkbox focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:focus:shadow-outline-gray"
  142 + />
  143 + <span class="ml-2">
  144 + I agree to the
  145 + <span class="underline">privacy policy</span>
  146 + </span>
  147 + </label>
  148 + </div>
  149 +</div>
  150 +
  151 +<!-- Validation inputs -->
  152 + <!--<h4
  153 + class="mb-4 text-lg font-semibold text-gray-600 dark:text-gray-300"
  154 + >
  155 + Validation
  156 + </h4>
  157 + <div
  158 + class="px-4 py-3 mb-8 bg-white rounded-lg shadow-md dark:bg-gray-800"
  159 + >
  160 + <!-- Invalid input -->
  161 + <!--<label class="block text-sm">
  162 + <span class="text-gray-700 dark:text-gray-400">
  163 + Invalid input
  164 + </span>
  165 + <input
  166 + class="block w-full mt-1 text-sm border-red-600 dark:text-gray-300 dark:bg-gray-700 focus:border-red-400 focus:outline-none focus:shadow-outline-red form-input"
  167 + placeholder="Jane Doe"
  168 + />
  169 + <span class="text-xs text-red-600 dark:text-red-400">
  170 + Your password is too short.
  171 + </span>
  172 + </label>
  173 +
  174 + <!-- Valid input -->
  175 + <!--<label class="block mt-4 text-sm">
  176 + <span class="text-gray-700 dark:text-gray-400">
  177 + Valid input
  178 + </span>
  179 + <input
  180 + class="block w-full mt-1 text-sm border-green-600 dark:text-gray-300 dark:bg-gray-700 focus:border-green-400 focus:outline-none focus:shadow-outline-green form-input"
  181 + placeholder="Jane Doe"
  182 + />
  183 + <span class="text-xs text-green-600 dark:text-green-400">
  184 + Your password is strong.
  185 + </span>
  186 + </label>
  187 +
  188 + <!-- Helper text -->
  189 + <!--<label class="block mt-4 text-sm">
  190 + <span class="text-gray-700 dark:text-gray-400">
  191 + Helper text
  192 + </span>
  193 + <input
  194 + class="block w-full mt-1 text-sm dark:text-gray-300 dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:focus:shadow-outline-gray form-input"
  195 + placeholder="Jane Doe"
  196 + />
  197 + <span class="text-xs text-gray-600 dark:text-gray-400">
  198 + Your password must be at least 6 characters long.
  199 + </span>
  200 + </label>
  201 +</div>
  202 +
  203 +<!-- Inputs with icons -->
  204 + <!--<h4
  205 + class="mb-4 text-lg font-semibold text-gray-600 dark:text-gray-300"
  206 + >
  207 + Icons
  208 + </h4>
  209 + <div
  210 + class="px-4 py-3 mb-8 bg-white rounded-lg shadow-md dark:bg-gray-800"
  211 + >
  212 + <label class="block text-sm">
  213 + <span class="text-gray-700 dark:text-gray-400">Icon left</span>
  214 + <!-- focus-within sets the color for the icon when input is focused -->
  215 + <!--<div
  216 + class="relative text-gray-500 focus-within:text-purple-600 dark:focus-within:text-purple-400"
  217 + >
  218 + <input
  219 + class="block w-full pl-10 mt-1 text-sm text-black dark:text-gray-300 dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:focus:shadow-outline-gray form-input"
  220 + placeholder="Jane Doe"
  221 + />
  222 + <div
  223 + class="absolute inset-y-0 flex items-center ml-3 pointer-events-none"
  224 + >
  225 + <svg
  226 + class="w-5 h-5"
  227 + aria-hidden="true"
  228 + fill="none"
  229 + stroke-linecap="round"
  230 + stroke-linejoin="round"
  231 + stroke-width="2"
  232 + viewBox="0 0 24 24"
  233 + stroke="currentColor"
  234 + >
  235 + <path
  236 + d="M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"
  237 + ></path>
  238 + </svg>
  239 + </div>
  240 + </div>
  241 +</label>
  242 +
  243 +<label class="block mt-4 text-sm">
  244 + <span class="text-gray-700 dark:text-gray-400">Icon right</span>
  245 + <!-- focus-within sets the color for the icon when input is focused -->
  246 + <!--<div
  247 + class="relative text-gray-500 focus-within:text-purple-600 dark:focus-within:text-purple-400"
  248 + >
  249 + <input
  250 + class="block w-full pr-10 mt-1 text-sm text-black dark:text-gray-300 dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:focus:shadow-outline-gray form-input"
  251 + placeholder="Jane Doe"
  252 + />
  253 + <div
  254 + class="absolute inset-y-0 right-0 flex items-center mr-3 pointer-events-none"
  255 + >
  256 + <svg
  257 + class="w-5 h-5"
  258 + aria-hidden="true"
  259 + fill="none"
  260 + stroke-linecap="round"
  261 + stroke-linejoin="round"
  262 + stroke-width="2"
  263 + viewBox="0 0 24 24"
  264 + stroke="currentColor"
  265 + >
  266 + <path
  267 + d="M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"
  268 + ></path>
  269 + </svg>
  270 + </div>
  271 + </div>
  272 +</label>
  273 +</div>
  274 +
  275 +<!-- Inputs with buttons -->
  276 + <!--<h4
  277 + class="mb-4 text-lg font-semibold text-gray-600 dark:text-gray-300"
  278 + >
  279 + Buttons
  280 + </h4>
  281 + <div
  282 + class="px-4 py-3 mb-8 bg-white rounded-lg shadow-md dark:bg-gray-800"
  283 + >
  284 + <label class="block text-sm">
  285 + <span class="text-gray-700 dark:text-gray-400">
  286 + Button left
  287 + </span>
  288 + <div class="relative">
  289 + <input
  290 + class="block w-full pl-20 mt-1 text-sm dark:text-gray-300 dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:focus:shadow-outline-gray form-input"
  291 + placeholder="Jane Doe"
  292 + />
  293 + <button
  294 + class="absolute inset-y-0 px-4 text-sm font-medium leading-5 text-white transition-colors duration-150 bg-purple-600 border border-transparent rounded-l-md active:bg-purple-600 hover:bg-purple-700 focus:outline-none focus:shadow-outline-purple dark:focus:shadow-outline-gray"
  295 + >
  296 + Click
  297 + </button>
  298 + </div>
  299 + </label>
  300 +
  301 + <label class="block mt-4 text-sm">
  302 + <span class="text-gray-700 dark:text-gray-400">
  303 + Button right
  304 + </span>
  305 + <div
  306 + class="relative text-gray-500 focus-within:text-purple-600"
  307 + >
  308 + <input
  309 + class="block w-full pr-20 mt-1 text-sm text-black dark:text-gray-300 dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:focus:shadow-outline-gray form-input"
  310 + placeholder="Jane Doe"
  311 + />
  312 + <button
  313 + class="absolute inset-y-0 right-0 px-4 text-sm font-medium leading-5 text-white transition-colors duration-150 bg-purple-600 border border-transparent rounded-r-md active:bg-purple-600 hover:bg-purple-700 focus:outline-none focus:shadow-outline-purple"
  314 + >
  315 + Click
  316 + </button>
  317 + </div>
  318 + </label>
  319 + </div>-->
  320 +@endsection
resources/views/admin/employer/index.blade.php
... ... @@ -88,10 +88,14 @@
88 88 {{ $user->created_at }}
89 89 </td>
90 90 <td class="px-4 py-3 text-sm">
91   - <a href="">Изменить</a>
  91 + @if ($user->id > 1)
  92 + <a href="{{ route('admin.user-profile', ['user' => $user->id]) }}">Изменить</a>
  93 + @endif
92 94 </td>
93 95 <td class="px-4 py-3 text-sm">
  96 + @if ($user->id > 1)
94 97 <input type="checkbox" class="checkban" value="{{$user->id}}" name="ban_{{$user->id}}" {{ ($user->is_ban) ? "checked" : "" }}/>
  98 + @endif
95 99 </td>
96 100 </tr>
97 101 @endforeach
resources/views/admin/password.blade.php
... ... @@ -0,0 +1,58 @@
  1 +@extends('layout.admin', ['title' => 'Админка - Смена пароля'])
  2 +
  3 +@section('content')
  4 + <h4 class="mb-4 text-lg font-semibold text-gray-600 dark:text-gray-300">
  5 + Вы в системе, как {{ $username }}
  6 + </h4>
  7 + <form method="POST" action="">
  8 + @csrf
  9 + <div class="px-4 py-3 mb-8 bg-white rounded-lg shadow-md dark:bg-gray-800">
  10 + <label class="block text-sm">
  11 + <span class="text-gray-700 dark:text-gray-400">Старый пароль</span>
  12 + <input name="old_password" id="old_password" type="password"
  13 + 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"
  14 + placeholder="Старый пароль" value=""
  15 + />
  16 + @error('old_password')
  17 + <span class="text-xs text-red-600 dark:text-red-400">
  18 + {{ $message }}
  19 + </span>
  20 + @enderror
  21 + </label><br>
  22 +
  23 + <label class="block text-sm">
  24 + <span class="text-gray-700 dark:text-gray-400">Новый пароль </span>
  25 + <input name="password" id="password"
  26 + 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 + placeholder="Новый пароль" value=""
  28 + />
  29 + @error('password')
  30 + <span class="text-xs text-red-600 dark:text-red-400">
  31 + {{ $message }}
  32 + </span>
  33 + @enderror
  34 + </label><br>
  35 +
  36 + <label class="block text-sm">
  37 + <span class="text-gray-700 dark:text-gray-400">Новый пароль (еще раз)</span>
  38 + <input name="password_confirmation" id="password_confirmation"
  39 + 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"
  40 + placeholder="Новый пароль" value=""
  41 + />
  42 + @error('password_confirmation')
  43 + <span class="text-xs text-red-600 dark:text-red-400">
  44 + {{ $message }}
  45 + </span>
  46 + @enderror
  47 + </label><br>
  48 +
  49 + <div class="flex flex-col flex-wrap mb-4 space-y-4 md:flex-row md:items-end md:space-x-4">
  50 + <div>
  51 + <button type="submit" class="px-3 py-1 text-sm font-medium leading-5 text-white transition-colors duration-150 bg-purple-600 border border-transparent rounded-md active:bg-purple-600 hover:bg-purple-700 focus:outline-none focus:shadow-outline-purple">
  52 + Сменить пароль
  53 + </button>
  54 + </div>
  55 + </div>
  56 + </div>
  57 + </form>
  58 +@endsection
resources/views/admin/profile.blade.php
... ... @@ -5,6 +5,7 @@
5 5 Личные данные
6 6 </h4>
7 7 <form method="POST" action="">
  8 + @csrf
8 9 <div class="px-4 py-3 mb-8 bg-white rounded-lg shadow-md dark:bg-gray-800">
9 10 <label class="block text-sm">
10 11 <span class="text-gray-700 dark:text-gray-400">Имя/Псевдоним/Имя компании</span>
... ... @@ -23,7 +24,7 @@
23 24 <span class="text-gray-700 dark:text-gray-400">Email</span>
24 25 <input name="email" id="email"
25 26 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"
26   - placeholder="Почта" value="{{ old('email') ?? $config->email ?? '' }}"
  27 + placeholder="Почта" value="{{ old('email') ?? $user->email ?? '' }}"
27 28 />
28 29 @error('email')
29 30 <span class="text-xs text-red-600 dark:text-red-400">
... ... @@ -117,7 +118,7 @@
117 118 <button type="submit" class="px-3 py-1 text-sm font-medium leading-5 text-white transition-colors duration-150 bg-purple-600 border border-transparent rounded-md active:bg-purple-600 hover:bg-purple-700 focus:outline-none focus:shadow-outline-purple">
118 119 Сохранить
119 120 </button>
120   - <a class="px-3 py-1 text-sm font-medium leading-5 text-white transition-colors duration-150 bg-purple-600 border border-transparent rounded-md active:bg-purple-600 hover:bg-purple-700 focus:outline-none focus:shadow-outline-purple">
  121 + <a href="{{ route('admin.password') }}" class="px-3 py-1 text-sm font-medium leading-5 text-white transition-colors duration-150 bg-purple-600 border border-transparent rounded-md active:bg-purple-600 hover:bg-purple-700 focus:outline-none focus:shadow-outline-purple">
121 122 Сменить пароль
122 123 </a>
123 124 </div>
resources/views/admin/users/index.blade.php
... ... @@ -127,7 +127,9 @@
127 127 @endif
128 128 </td>
129 129 <td class="px-4 py-3 text-sm">
  130 + @if ($user->id > 1)
130 131 <input type="checkbox" class="checkban" value="{{$user->id}}" name="ban_{{$user->id}}" {{ ($user->is_ban) ? "checked" : "" }}/>
  132 + @endif
131 133 </td>
132 134 <td class="px-4 py-3 text-sm">
133 135 <input type="checkbox" class="checknew" value="{{$user->id}}" name="new_{{$user->id}}" {{ ($user->is_new) ? "checked" : "" }}/>
resources/views/admin/users/index_ajax.blade.php
... ... @@ -40,7 +40,9 @@
40 40 @endif
41 41 </td>
42 42 <td class="px-4 py-3 text-sm">
  43 + @if ($user->id > 1)
43 44 <input type="checkbox" class="checkban" value="{{$user->id}}" name="ban_{{$user->id}}" {{ ($user->is_ban) ? "checked" : "" }}/>
  45 + @endif
44 46 </td>
45 47 <td class="px-4 py-3 text-sm">
46 48 <input type="checkbox" class="checknew" value="{{$user->id}}" name="new_{{$user->id}}" {{ ($user->is_new) ? "checked" : "" }}/>
resources/views/admin/users/profile.blade.php
... ... @@ -0,0 +1,106 @@
  1 +@extends('layout.admin', ['title' => 'Админка - Профиль '.$user->name])
  2 +
  3 +@section('content')
  4 + <h4 class="mb-4 text-lg font-semibold text-gray-600 dark:text-gray-300">
  5 + Личные данные пользователя "{{$user->name}} ({{$user->id}})"
  6 + </h4>
  7 + <form method="POST" action="">
  8 + @csrf
  9 + <div class="px-4 py-3 mb-8 bg-white rounded-lg shadow-md dark:bg-gray-800">
  10 + <label class="block text-sm">
  11 + <span class="text-gray-700 dark:text-gray-400">Имя/Псевдоним/Имя компании</span>
  12 + <input name="name" id="name"
  13 + 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"
  14 + placeholder="Псевдоним для админки" value="{{ old('name') ?? $user->name ?? '' }}"
  15 + />
  16 + @error('name')
  17 + <span class="text-xs text-red-600 dark:text-red-400">
  18 + {{ $message }}
  19 + </span>
  20 + @enderror
  21 + </label><br>
  22 +
  23 + <!--<label class="block text-sm">
  24 + <span class="text-gray-700 dark:text-gray-400">Email</span>
  25 + <input name="email" id="email"
  26 + 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 + placeholder="Почта" value="{{ old('email') ?? $user->email ?? '' }}"
  28 + />
  29 + @error('email')
  30 + <span class="text-xs text-red-600 dark:text-red-400">
  31 + {{ $message }}
  32 + </span>
  33 + @enderror
  34 + </label><br>-->
  35 +
  36 + <label class="block text-sm">
  37 + <span class="text-gray-700 dark:text-gray-400">Телефон</span>
  38 + <input name="telephone" id="telephone"
  39 + 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"
  40 + placeholder="Телефон" value="{{ old('telephone') ?? $user->telephone ?? '' }}"
  41 + />
  42 + @error('telephone')
  43 + <span class="text-xs text-red-600 dark:text-red-400">
  44 + {{ $message }}
  45 + </span>
  46 + @enderror
  47 + </label><br>
  48 +
  49 + <label class="block text-sm">
  50 + <span class="text-gray-700 dark:text-gray-400">Фамилия</span>
  51 + <input name="surname" id="surname"
  52 + 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"
  53 + placeholder="Фамилия" value="{{ old('surname') ?? $user->surname ?? '' }}"
  54 + />
  55 + @error('surname')
  56 + <span class="text-xs text-red-600 dark:text-red-400">
  57 + {{ $message }}
  58 + </span>
  59 + @enderror
  60 + </label><br>
  61 +
  62 + <label class="block text-sm">
  63 + <span class="text-gray-700 dark:text-gray-400">Имя человека</span>
  64 + <input name="name_man" id="name_man"
  65 + 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"
  66 + placeholder="Имя человека" value="{{ old('name_man') ?? $user->name_man ?? '' }}"
  67 + />
  68 + @error('name_man')
  69 + <span class="text-xs text-red-600 dark:text-red-400">
  70 + {{ $message }}
  71 + </span>
  72 + @enderror
  73 + </label><br>
  74 +
  75 + <label class="block text-sm">
  76 + <span class="text-gray-700 dark:text-gray-400">Отчество</span>
  77 + <input name="surname2" id="surname2"
  78 + 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"
  79 + placeholder="Отчество" value="{{ old('surname2') ?? $user->surname2 ?? '' }}"
  80 + />
  81 + @error('surname2')
  82 + <span class="text-xs text-red-600 dark:text-red-400">
  83 + {{ $message }}
  84 + </span>
  85 + @enderror
  86 + </label><br>
  87 +
  88 +
  89 +
  90 + <div class="flex flex-col flex-wrap mb-4 space-y-4 md:flex-row md:items-end md:space-x-4">
  91 + <div>
  92 + <button type="submit" class="px-3 py-1 text-sm font-medium leading-5 text-white transition-colors duration-150 bg-purple-600 border border-transparent rounded-md active:bg-purple-600 hover:bg-purple-700 focus:outline-none focus:shadow-outline-purple">
  93 + Сохранить
  94 + </button>
  95 + </div>
  96 + <div>
  97 + @if ($visible==true)
  98 + <a href="{{$link}}" style="padding-bottom: 15px">
  99 + {{ $caption }}
  100 + </a>
  101 + @endif
  102 + </div>
  103 + </div>
  104 + </div>
  105 + </form>
  106 +@endsection
resources/views/admin/worker/edit.blade.php
resources/views/admin/worker/index.blade.php
... ... @@ -95,10 +95,14 @@
95 95 {{ $user->created_at }}
96 96 </td>
97 97 <td class="px-4 py-3 text-sm">
98   - <a href="">Изменить</a>
  98 + @if ($user->id > 1)
  99 + <a href="{{ route('admin.user-profile', ['user' => $user->id]) }}">Изменить</a>
  100 + @endif
99 101 </td>
100 102 <td class="px-4 py-3 text-sm">
101   - <input type="checkbox" class="checkban" value="{{$user->id}}" name="ban_{{$user->id}}" {{ ($user->is_ban) ? "checked" : "" }}/>
  103 + @if ($user->id > 1)
  104 + <input type="checkbox" class="checkban" value="{{$user->id}}" name="ban_{{$user->id}}" {{ ($user->is_ban) ? "checked" : "" }}/>
  105 + @endif
102 106 </td>
103 107 </tr>
104 108 @endforeach
resources/views/layout/admin.blade.php
... ... @@ -913,6 +913,32 @@
913 913 <span>Список админов &RightArrow;</span>
914 914 </a>
915 915  
  916 + @if ($message = Session::get('success'))
  917 + <section>
  918 + <div class="alert alert-success alert-dismissible mt-0" role="alert">
  919 + <button type="button" class="close" data-dismiss="alert" aria-label="Закрыть">
  920 + <span aria-hidden="true">&times;</span>
  921 + </button>
  922 + {{ $message }}
  923 + </div>
  924 + </section>
  925 + @endif
  926 +
  927 + @if ($errors->any())
  928 + <section>
  929 + <div class="alert alert-danger alert-dismissible mt-4" role="alert">
  930 + <button type="button" class="close" data-dismiss="alert" aria-label="Закрыть">
  931 + <span aria-hidden="true">&times;</span>
  932 + </button>
  933 + <ul class="mb-0">
  934 + @foreach ($errors->all() as $error)
  935 + <li>{{ $error }}</li>
  936 + @endforeach
  937 + </ul>
  938 + </div>
  939 + </section>
  940 + @endif
  941 +
916 942 @yield('content')
917 943  
918 944 <!-- Cards
... ... @@ -74,11 +74,28 @@ Route::group([
74 74  
75 75 // кабинет главная страница
76 76 Route::get('cabinet', [AdminController::class, 'index'])->name('index');
77   - // кабинет профиль - форма
  77 +
  78 + // кабинет профиль админа - форма
78 79 Route::get('profile', [AdminController::class, 'profile'])->name('profile');
79   - // кабинет профиль - сохранение формы
  80 + // кабинет профиль админа - сохранение формы
80 81 Route::post('profile', [AdminController::class, 'store_profile'])->name('store_profile');
81 82  
  83 + // кабинет профиль - форма пароли
  84 + Route::get('password', [AdminController::class, 'profile_password'])->name('password');
  85 + // кабинет профиль - сохранение формы пароля
  86 + Route::post('password', [AdminController::class, 'profile_password_new'])->name('password');
  87 +
  88 +
  89 + // кабинет профиль пользователя - форма
  90 + Route::get('user-profile/{user}', [AdminController::class, 'profile_user'])->name('user-profile');
  91 + // кабинет профиль пользователя - сохранение формы
  92 + Route::post('user-profile/{user}', [AdminController::class, 'store_profile_user'])->name('user-store_profile');
  93 +
  94 + // кабинет профиль работодатель - форма
  95 + Route::get('employer-profile/{employer}', [EmployersController::class, 'form_update_employer'])->name('employer-profile');
  96 + // кабинет профиль работник - форма
  97 + Route::post('worker-profile/{worker}', [WorkersController::class, 'form_update_worker'])->name('worker-profile');
  98 +
82 99 // кабинет настройки - форма
83 100 Route::get('config', [AdminController::class, 'config_form'])->name('config');
84 101 // кабинет настройки сохранение формы