Commit 622420a678ad3ad0772755f7ecd929da84a5153c

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

Расширение функционала админки (работодатели)

Showing 5 changed files with 248 additions and 124 deletions Side-by-side Diff

app/Http/Controllers/Admin/EmployersController.php
... ... @@ -9,6 +9,7 @@ use App\Models\Employer;
9 9 use App\Models\Static_ad;
10 10 use App\Models\User;
11 11 use Illuminate\Http\Request;
  12 +use Illuminate\Support\Facades\DB;
12 13 use Illuminate\Support\Facades\Storage;
13 14 use Illuminate\Support\Facades\Validator;
14 15  
... ... @@ -21,7 +22,7 @@ class EmployersController extends Controller
21 22 $user->update($request->all());
22 23 }
23 24  
24   - $users = User::where('is_worker', '0');
  25 + /*$users = User::with('employers')->where('is_worker', '0');
25 26 $find_key = "";
26 27 if (isset($request->find)) {
27 28 $find_key = $request->find;
... ... @@ -30,8 +31,23 @@ class EmployersController extends Controller
30 31 ->orWhere('email', 'LIKE', "%$find_key%")
31 32 ->orWhere('telephone', 'LIKE', "%$find_key%");
32 33 });
  34 + }*/
  35 +
  36 + $users = User::select(['users.*', 'emp.id as emp_id', 'emp.*'])->join('employers as emp','emp.user_id','users.id')
  37 + ->where('users.is_worker', '0');
  38 + $find_key = "";
  39 + if (isset($request->find)) {
  40 + $find_key = $request->find;
  41 + $users = $users->where(function($query) use($find_key) {
  42 + $query->Where('users.name', 'LIKE', "%$find_key%")
  43 + ->orWhere('emp.email', 'LIKE', "%$find_key%")
  44 + ->orWhere('emp.telephone', 'LIKE', "%$find_key%");
  45 + });
33 46 }
  47 +
  48 + //DB::enableQueryLog();
34 49 $users = $users->paginate(15);
  50 + //dd(DB::getQueryLog());
35 51  
36 52 if ($request->ajax()) {
37 53 return view('admin.employer.index_ajax', compact('users'));
... ... @@ -52,6 +68,10 @@ class EmployersController extends Controller
52 68 unset($params['email']);
53 69 unset($params['address']);
54 70 unset($params['site']);
  71 + unset($params['status_hidden']);
  72 + unset($params['oficial_status']);
  73 + unset($params['social_is']);
  74 + unset($params['sending_is']);
55 75  
56 76 $rules = [
57 77 'name' => 'required|string|max:255',
... ... @@ -85,6 +105,10 @@ class EmployersController extends Controller
85 105 $employer->address = $request->address;
86 106 $employer->site = $request->site;
87 107 $employer->text = $request->text;
  108 + $employer->status_hidden = $request->status_hidden;
  109 + $employer->oficial_status = $request->oficial_status;
  110 + $employer->social_is = $request->social_is;
  111 + $employer->sending_is = $request->sending_is;
88 112  
89 113 if ($request->has('logo')) {
90 114 if (!empty($employer->logo)) {
public/assets/css/tabs.css
... ... @@ -0,0 +1,47 @@
  1 +.tabs {
  2 + font-size: 0;
  3 +}
  4 +
  5 +.tabs>input[type="radio"] {
  6 + display: none;
  7 +}
  8 +
  9 +.tabs>div {
  10 + /* скрыть контент по умолчанию */
  11 + display: none;
  12 + border: 1px solid #e0e0e0;
  13 + padding: 10px 15px;
  14 + font-size: 16px;
  15 +}
  16 +
  17 +/* отобразить контент, связанный с вабранной радиокнопкой (input type="radio") */
  18 +#tab-btn-1:checked~#content-1,
  19 +#tab-btn-2:checked~#content-2,
  20 +#tab-btn-3:checked~#content-3 {
  21 + display: block;
  22 +}
  23 +
  24 +.tabs>label {
  25 + display: inline-block;
  26 + text-align: center;
  27 + vertical-align: middle;
  28 + user-select: none;
  29 + background-color: #f5f5f5;
  30 + border: 1px solid #e0e0e0;
  31 + padding: 2px 8px;
  32 + font-size: 16px;
  33 + line-height: 1.5;
  34 + transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out;
  35 + cursor: pointer;
  36 + position: relative;
  37 + top: 1px;
  38 +}
  39 +
  40 +.tabs>label:not(:first-of-type) {
  41 + border-left: none;
  42 +}
  43 +
  44 +.tabs>input[type="radio"]:checked+label {
  45 + background-color: #fff;
  46 + border-bottom: 1px solid #fff;
  47 +}
resources/views/admin/employer/edit.blade.php
... ... @@ -5,143 +5,195 @@
5 5 Работодатель-пользователь: "{{$employer->users->name_man}} ({{$employer->user_id}})"
6 6 </h4>
7 7 <form method="POST" action="" enctype="multipart/form-data">
8   - @csrf
9 8 <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') ?? $employer->users->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>
  9 + @csrf
  10 + <div class="tabs">
  11 + <input type="radio" name="tab-btn" id="tab-btn-1" value="" checked>
  12 + <label for="tab-btn-1">Персональная информация</label>
  13 + <input type="radio" name="tab-btn" id="tab-btn-2" value="">
  14 + <label for="tab-btn-2">Настройки</label>
  15 + <!--<input type="radio" name="tab-btn" id="tab-btn-3" value="">
  16 + <label for="tab-btn-3">Вкладка 3</label>-->
  17 + <div id="content-1">
  18 +
  19 + <label class="block text-sm">
  20 + <span class="text-gray-700 dark:text-gray-400">Имя компании</span>
  21 + <input name="name" id="name"
  22 + 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"
  23 + placeholder="Имя компании" value="{{ old('name') ?? $employer->users->name ?? '' }}"
  24 + />
  25 + @error('name')
  26 + <span class="text-xs text-red-600 dark:text-red-400">
  27 + {{ $message }}
  28 + </span>
  29 + @enderror
  30 + </label><br>
22 31  
23   - <label class="block text-sm">
24   - <span class="text-gray-700 dark:text-gray-400">Email</span>
25   - <input name="email" id="email"
  32 + <label class="block text-sm">
  33 + <span class="text-gray-700 dark:text-gray-400">Email</span>
  34 + <input name="email" id="email"
26 35 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 36 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>
  37 + />
  38 + @error('email')
  39 + <span class="text-xs text-red-600 dark:text-red-400">
  40 + {{ $message }}
  41 + </span>
  42 + @enderror
  43 + </label><br>
35 44  
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>
  45 + <label class="block text-sm">
  46 + <span class="text-gray-700 dark:text-gray-400">Телефон</span>
  47 + <input name="telephone" id="telephone"
  48 + 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"
  49 + placeholder="Телефон" value="{{ old('telephone') ?? $employer->telephone ?? '' }}"
  50 + />
  51 + @error('telephone')
  52 + <span class="text-xs text-red-600 dark:text-red-400">
  53 + {{ $message }}
  54 + </span>
  55 + @enderror
  56 + </label><br>
48 57  
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>
  58 + <label class="block text-sm">
  59 + <span class="text-gray-700 dark:text-gray-400">Адрес</span>
  60 + <input name="address" id="address"
  61 + 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"
  62 + placeholder="Адрес" value="{{ old('address') ?? $employer->address ?? '' }}"
  63 + />
  64 + @error('address')
  65 + <span class="text-xs text-red-600 dark:text-red-400">
  66 + {{ $message }}
  67 + </span>
  68 + @enderror
  69 + </label><br>
61 70  
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>
  71 + <label class="block text-sm">
  72 + <span class="text-gray-700 dark:text-gray-400">Сайт</span>
  73 + <input name="site" id="site"
  74 + 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"
  75 + placeholder="Сайт" value="{{ old('site') ?? $employer->site ?? '' }}"
  76 + />
  77 + @error('site')
  78 + <span class="text-xs text-red-600 dark:text-red-400">
  79 + {{ $message }}
  80 + </span>
  81 + @enderror
  82 + </label><br>
74 83  
75   - <label class="block text-sm">
76   - <h4 class="mb-4 text-lg font-semibold text-gray-600 dark:text-gray-300">
77   - Права работодателя:
78   - </h4>
79   - <p style="float:left; margin-right: 10px">Просмотр базы резюме </p>
80   - <input type="hidden" name="is_lookin" value="0" />
81   - <input name="is_lookin" <? if ($employer->users->is_lookin) echo "checked";?>
82   - class="block 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 "
83   - placeholder="" type="checkbox" value="1"
84   - /><br>
  84 + <label class="block text-sm">
  85 + <span class="text-gray-700 dark:text-gray-400">Лого</span>
85 86  
86   - <p style="float:left; margin-right: 10px">Отправка сообщений</p>
87   - <input type="hidden" name="is_message" value="0" />
88   - <input name="is_message" id="is_message" <? if ($employer->users->is_message) echo "checked";?>
89   - class="block 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 "
90   - placeholder="" type="checkbox" value="1"
91   - /><br>
  87 + <input name="logo" id="logo" type="file"
  88 + 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"
  89 + placeholder="Лого" value=""
  90 + />
  91 + @isset($employer->logo)
  92 + <img src="<?=asset(Storage::url($employer->logo))?>" width="150"/>
  93 + @endisset
  94 + @error('logo')
  95 + <span class="text-xs text-red-600 dark:text-red-400">
  96 + {{ $message }}
  97 + </span>
  98 + @enderror
  99 + </label><br>
92 100  
93   - <p style="float:left; margin-right: 10px">Публикация вакансий</p>
94   - <input type="hidden" name="is_public" value="0" />
95   - <input name="is_public" id="is_public" <? if ($employer->users->is_public) echo "checked";?>
96   - class="block 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 "
97   - placeholder="" type="checkbox" value="1"
98   - /><br>
  101 + <label class="block mt-4 text-sm">
  102 + <span class="text-gray-700 dark:text-gray-400">Описание</span>
  103 + <textarea name="text" id="text"
  104 + 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"
  105 + rows="3"
  106 + placeholder="Описание компании"
  107 + >{{ old('text') ?? $employer->text ?? '' }}</textarea>
  108 + </label>
99 109  
100   - </label>
  110 + </div>
  111 + <div id="content-2">
  112 + <label class="block text-sm">
  113 + <h4 class="mb-4 text-lg font-semibold text-gray-600 dark:text-gray-300">
  114 + Права работодателя:
  115 + </h4>
  116 + <p class="text-gray-700 dark:text-gray-400" style="float:left; margin-right: 10px">Просмотр базы резюме </p>
  117 + <input type="hidden" name="is_lookin" value="0" />
  118 + <input name="is_lookin" <? if ($employer->users->is_lookin) echo "checked";?>
  119 + class="block 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 "
  120 + placeholder="" type="checkbox" value="1"
  121 + /><br>
101 122  
102   - <label class="block text-sm">
103   - <span class="text-gray-700 dark:text-gray-400">Лого</span>
  123 + <p class="text-gray-700 dark:text-gray-400" style="float:left; margin-right: 10px">Отправка сообщений</p>
  124 + <input type="hidden" name="is_message" value="0" />
  125 + <input name="is_message" id="is_message" <? if ($employer->users->is_message) echo "checked";?>
  126 + class="block 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 "
  127 + placeholder="" type="checkbox" value="1"
  128 + /><br>
104 129  
105   - <input name="logo" id="logo" type="file"
106   - 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"
107   - placeholder="Лого" value=""
108   - />
109   - @isset($employer->logo)
110   - <img src="<?=asset(Storage::url($employer->logo))?>" width="150"/>
111   - @endisset
112   - @error('logo')
113   - <span class="text-xs text-red-600 dark:text-red-400">
114   - {{ $message }}
115   - </span>
116   - @enderror
117   - </label><br>
  130 + <p class="text-gray-700 dark:text-gray-400" style="float:left; margin-right: 10px">Публикация вакансий</p>
  131 + <input type="hidden" name="is_public" value="0" />
  132 + <input name="is_public" id="is_public" <? if ($employer->users->is_public) echo "checked";?>
  133 + class="block 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 "
  134 + placeholder="" type="checkbox" value="1"
  135 + /><br>
  136 +
  137 + </label>
  138 +
  139 + <label class="block text-sm">
  140 + <p class="text-gray-700 dark:text-gray-400" style="float:left; margin-right: 10px">Работодатель скрыт </p>
  141 + <input type="hidden" name="status_hidden" value="0" />
  142 + <input name="status_hidden" <? if ($employer->status_hidden) echo "checked";?>
  143 + class="block 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 "
  144 + placeholder="" type="checkbox" value="1"
  145 + />
  146 + </label><br>
  147 +
  148 + <label class="block text-sm">
  149 + <p class="text-gray-700 dark:text-gray-400" style="float:left; margin-right: 10px">Компания подтверждена </p>
  150 + <input type="hidden" name="oficial_status" value="0" />
  151 + <input name="oficial_status" <? if ($employer->oficial_status) echo "checked";?>
  152 + class="block 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 "
  153 + placeholder="" type="checkbox" value="1"
  154 + />
  155 + </label><br>
118 156  
119   - <label class="block mt-4 text-sm">
120   - <span class="text-gray-700 dark:text-gray-400">Описание</span>
121   - <textarea name="text" id="text"
122   - 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"
123   - rows="3"
124   - placeholder="Описание компании"
125   - >{{ old('text') ?? $employer->text ?? '' }}</textarea>
126   - </label>
  157 + <label class="block text-sm">
  158 + <p class="text-gray-700 dark:text-gray-400" style="float:left; margin-right: 10px">Разрешение публикации в соц.сетях </p>
  159 + <input type="hidden" name="social_is" value="0" />
  160 + <input name="social_is" <? if ($employer->social_is) echo "checked";?>
  161 + class="block 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 "
  162 + placeholder="" type="checkbox" value="1"
  163 + />
  164 + </label><br>
127 165  
  166 + <label class="block text-sm">
  167 + <p class="text-gray-700 dark:text-gray-400" style="float:left; margin-right: 10px">Рассылка </p>
  168 + <input type="hidden" name="sending_is" value="0" />
  169 + <input name="sending_is" <? if ($employer->sending_is) echo "checked";?>
  170 + class="block 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 "
  171 + placeholder="" type="checkbox" value="1"
  172 + />
  173 + </label><br>
128 174  
129   - <div class="flex flex-col flex-wrap mb-4 space-y-4 md:flex-row md:items-end md:space-x-4">
130   - <div>
131   - <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">
132   - Сохранить
133   - </button>
134   - </div>
135   - <div>
136   - <a href="">Флот</a>
137   - </div>
138   - <div>
139   - <a href="">Вакансии</a>
140   - </div>
141   - <div>
142   - <a href="">Контакты</a>
143   - </div>
144 175 </div>
  176 + <div id="content-3">
  177 + Содержимое 3...
  178 + </div>
  179 + </div>
  180 + <br>
  181 + <div class="flex flex-col flex-wrap mb-4 space-y-4 md:flex-row md:items-end md:space-x-4">
  182 + <div>
  183 + <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">
  184 + Сохранить
  185 + </button>
  186 + </div>
  187 + <!--<div>
  188 + <a href="">Флот</a>
  189 + </div>
  190 + <div>
  191 + <a href="">Вакансии</a>
  192 + </div>
  193 + <div>
  194 + <a href="">Контакты</a>
  195 + </div>-->
  196 + </div>
145 197 </div>
146 198 </form>
147 199 <!--
resources/views/admin/employer/index.blade.php
... ... @@ -86,14 +86,14 @@
86 86  
87 87 </td>
88 88 <td class="px-4 py-3 text-sm">
89   - {{ $user->name_man }}
  89 + {{ $user->name_man }} ({{ $user->emp_id }})
90 90 </td>
91 91 <td class="px-4 py-3 text-sm">
92 92 {{ $user->created_at }}
93 93 </td>
94 94 <td class="px-4 py-3 text-sm">
95   - @if ($user->id > 1)
96   - <a href="{{ route('admin.user-profile', ['user' => $user->id]) }}">Изменить</a>
  95 + @if (!empty($user->emp_id))
  96 + <a href="{{ route('admin.employer-profile', ['employer' => $user->emp_id]) }}">Изменить</a>
97 97 @endif
98 98 </td>
99 99 <td class="px-4 py-3 text-sm">
resources/views/layout/admin.blade.php
... ... @@ -9,6 +9,7 @@
9 9 rel="stylesheet"
10 10 />
11 11 <link rel="stylesheet" href="{{ asset('./assets/css/tailwind.output.css')}}" />
  12 + <link rel="stylesheet" href="{{ asset('./assets/css/tabs.css')}}" />
12 13 <script
13 14 src="https://cdn.jsdelivr.net/gh/alpinejs/alpine@v2.x.x/dist/alpine.min.js"
14 15 defer