Commit d50cbef749496f891f1484af2cfeb3afb7f0c3fe

Authored by Андрей Ларионов
Exists in master

Merge branch 'master' of http://gitlab.nologostudio.ru/alarionov/rekamore-su

Showing 10 changed files Side-by-side Diff

app/Http/Controllers/Admin/UsersController.php
... ... @@ -81,7 +81,7 @@ class UsersController extends Controller
81 81  
82 82 public function add_store_bd(BaseUserRequest $request) {
83 83 $params = $request->all();
84   - $position_work = $request->position_work;
  84 + $positions_work = json_encode($request->input('positions_work', []));
85 85  
86 86 if ($request->has('file')) {
87 87 $params['file'] = $request->file('file')->store('basedata', 'public');
... ... @@ -94,7 +94,7 @@ class UsersController extends Controller
94 94 $user = User::create($params);
95 95 $user_id = $user->id;
96 96 $worker = new Worker();
97   - $worker->position_work = $position_work;
  97 + $worker->positions_work = $positions_work;
98 98 $worker->user_id = $user_id;
99 99 $worker->save();
100 100  
... ... @@ -109,7 +109,7 @@ class UsersController extends Controller
109 109  
110 110 public function update_bd(BaseUserRequest $request, User $user) {
111 111 $params = $request->all();
112   - $position_work = $request->position_work;
  112 + $positions_work = $request->input('positions_work', []);
113 113  
114 114 if ($request->has('file')) {
115 115 if (!empty($user->file)) Storage::delete($user->file);
... ... @@ -125,12 +125,12 @@ class UsersController extends Controller
125 125 $user->update($params);
126 126 if (isset($user->workers[0]->id)) {
127 127 $worker = Worker::find($user->workers[0]->id);
128   - $worker->position_work = $position_work;
  128 + $worker->positions_work = $positions_work;
129 129 $worker->save();
130 130 } else {
131 131 $worker = new Worker();
132 132 $worker->user_id = $user->id;
133   - $worker->position_work = $position_work;
  133 + $worker->positions_work = $positions_work;
134 134 $worker->save();
135 135 }
136 136  
app/Http/Controllers/EmployerController.php
... ... @@ -208,9 +208,12 @@ class EmployerController extends Controller
208 208  
209 209 //dd($request->all());
210 210 $Employer = Employer::query()->where('user_id', $id)->first();
211   - $vacancy_list = Ad_employer::query()->with('jobs')->
212   - with('jobs_code')->
213   - where('employer_id', $Employer->id);
  211 + $vacancy_list = Ad_employer::query()
  212 + ->with('jobs')
  213 + ->with('jobs_code')
  214 + ->where('employer_id', $Employer->id)
  215 + ->where('is_remove', 0)
  216 + ;
214 217  
215 218 if (($request->has('search')) && (!empty($request->get('search')))) {
216 219 $search = $request->get('search');
app/Models/Worker.php
... ... @@ -15,6 +15,7 @@ class Worker extends Model
15 15 'user_id',
16 16 'status_work',
17 17 'position_work',
  18 + 'positions_work',
18 19 'telephone',
19 20 'telephone2',
20 21 'persent_anketa',
... ... @@ -56,6 +57,28 @@ class Worker extends Model
56 57 'military_id_available'
57 58 ];
58 59  
  60 + /**
  61 + * Получить значение поля positions_work как массив.
  62 + *
  63 + * @param string $value
  64 + * @return array
  65 + */
  66 + public function getPositionsWorkAttribute($value)
  67 + {
  68 + return json_decode($value, true);
  69 + }
  70 +
  71 + /**
  72 + * Установить значение поля positions_work как JSON.
  73 + *
  74 + * @param array|string $value
  75 + * @return void
  76 + */
  77 + public function setPositionsWorkAttribute($value)
  78 + {
  79 + $this->attributes['positions_work'] = is_array($value) ? json_encode($value) : $value;
  80 + }
  81 +
59 82 /*
60 83 * Связь таблицы users с таблицей workers
61 84 */
... ... @@ -101,4 +124,10 @@ class Worker extends Model
101 124 return $this->hasMany(ResponseWork::class);
102 125 }
103 126  
  127 + public function getJobsAttribute()
  128 + {
  129 + $job_titles_ids = json_decode($this->attributes['positions_work'], true);
  130 + return Job_title::whereIn('id', $job_titles_ids)->get();
  131 + }
  132 +
104 133 }
database/migrations/2024_08_10_123217_alter_table_workers.php
... ... @@ -0,0 +1,34 @@
  1 +<?php
  2 +
  3 +use Illuminate\Database\Migrations\Migration;
  4 +use Illuminate\Database\Schema\Blueprint;
  5 +use Illuminate\Support\Facades\Schema;
  6 +
  7 +return new class extends Migration
  8 +{
  9 + /**
  10 + * Run the migrations.
  11 + *
  12 + * @return void
  13 + */
  14 + public function up()
  15 + {
  16 + Schema::table('workers', function (Blueprint $table) {
  17 + $table->string('positions_work', 255)->nullable(true)->after('position_work');
  18 + $table->integer('position_work')->nullable(true)->change();
  19 +
  20 + });
  21 + }
  22 +
  23 + /**
  24 + * Reverse the migrations.
  25 + *
  26 + * @return void
  27 + */
  28 + public function down()
  29 + {
  30 + Schema::table('workers', function (Blueprint $table) {
  31 + $table->dropColumn('positions_work');
  32 + });
  33 + }
  34 +};
public/js/chosen/chosen-sprite.png

538 Bytes

public/js/chosen/chosen-sprite@2x.png

738 Bytes

resources/views/admin/users/form.blade.php
1 1 <div class="px-4 py-3 mb-8 bg-white rounded-lg shadow-md dark:bg-gray-800">
2   - <!--<label class="block text-sm">
3   - <span class="text-gray-700 dark:text-gray-400">Имя/Псевдоним</span>
4   - <input name="name" id="name"
5   - 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"
6   - placeholder="Имя/Псевдоним" value="{{ old('name') ?? $user->name ?? '' }}"
7   - />
8   - @error('name')
9   - <span class="text-xs text-red-600 dark:text-red-400">
10   - {{ $message }}
11   - </span>
12   - @enderror
13   - </label><br>-->
  2 + @error('name')
  3 + {{ $message }}
  4 + @enderror
14 5  
15 6 <input name="name" id="name" type="hidden"
16 7 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"
... ... @@ -19,17 +10,16 @@
19 10  
20 11 <label class="block text-sm">
21 12 <span class="text-gray-700 dark:text-gray-400">Должность</span>
22   - <select name="position_work" id="position_work" class="form-control 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"
23   - ">
  13 + <select name="positions_work[]" id="positions_work[]" data-placeholder="Выберите должность..." multiple="multiple">
24 14 @isset($list_job_titles)
25 15 @foreach($list_job_titles as $job_title)
26 16 <option value="{{ $job_title->id }}"
27   - @if (isset($user->workers[0]->position_work))
28   - @if($job_title->id == $user->workers[0]->position_work)
29   - selected
30   - @endif
31   - @endif
32   - >{{ $job_title->name }} ({{ $job_title->id }})</option>
  17 + @if (in_array($job_title->id , $user->workers[0]->positions_work))
  18 + selected
  19 + @endif
  20 + >
  21 + {{ $job_title->name }} ({{ $job_title->id }})
  22 + </option>
33 23 @endforeach
34 24 @endisset
35 25 </select>
... ... @@ -148,3 +138,12 @@
148 138 </div>
149 139 </div>
150 140 </div>
  141 +
  142 +<script>
  143 + $(function(){
  144 + $('[name="positions_work[]"]').chosen({
  145 + no_results_text: 'Не добавлено ни одной должности.',
  146 + width: '100%'
  147 + })
  148 + });
  149 +</script>
resources/views/admin/users/index_bd.blade.php
... ... @@ -91,34 +91,11 @@
91 91 {{$user->id}}
92 92 </td>
93 93 <td class="px-4 py-3 text-xs">
94   - <!--<div class="flex items-center text-sm">
95   - <div class="relative hidden w-8 h-8 mr-3 rounded-full md:block">
96   - <div
97   - class="absolute inset-0 rounded-full shadow-inner"
98   - aria-hidden="true"
99   - ></div>
100   - </div>
101   - <div>
102   - <p class="font-semibold"><a href="{{ route('admin.users') }}">Пользователи</a></p>
103   - <p class="text-xs text-gray-600 dark:text-gray-400">
104   - Все пользователи сайта
105   - </p>
106   - </div>
107   - </div>
108   - -->
109   - <!--<a style="text-decoration: underline;" href="{{ route('admin.user-profile', ['user' => $user->id]) }}"></a>-->
110   -
111 94 {{ $user->name }}
112 95 </td>
113 96  
114 97 <td class="px-4 py-3 text-xs">
115 98 <div class="flex items-center text-sm">
116   - <!--<div class="relative hidden w-8 h-8 mr-3 rounded-full md:block">
117   - <div
118   - class="absolute inset-0 rounded-full shadow-inner"
119   - aria-hidden="true"
120   - ></div>
121   - </div>-->
122 99 <div>
123 100 <p class="font-semibold">{{ empty($user->employers->email) ? $user->email : $user->employers->email }}</p>
124 101 <p class="text-xs text-gray-600 dark:text-gray-400">
... ... @@ -128,29 +105,14 @@
128 105 </div>
129 106 </td>
130 107  
131   - <!--<td class="px-4 py-3 text-xs">
132   - <span class="px-2 py-1 font-semibold leading-tight text-green-700 bg-green-100 rounded-full dark:bg-green-700 dark:text-green-100">
133   - @if ($user->is_worker)
134   - Работник
135   - @else
136   - Работодатель
137   - @endif
138   - </span>
139   - @if ($user->admin)
140   - <span class="px-2 py-1 font-semibold leading-tight text-orange-700 bg-orange-100 rounded-full dark:text-white dark:bg-orange-600">
141   - Администратор
142   - </span>
143   - @endif
144   - @if ($user->is_bd)
145   - <span class="px-2 py-1 font-semibold leading-tight text-red-700 bg-red-100 rounded-full dark:text-red-100 dark:bg-red-700">
146   - База данных
147   - </span>
148   - @endif
149   - </td>-->
150   -
151 108 <td class="px-4 py-3 text-xs">
152   - @if (isset($user->jobtitles[0]->name))
153   - {{ $user->jobtitles[0]->name }}
  109 + @if (isset($user->workers[0]->positions_work))
  110 + @foreach($user->workers[0]->jobs as $job)
  111 + {{ $job->name }}
  112 + @if(!$loop->last)
  113 + <br>
  114 + @endif
  115 + @endforeach
154 116 @else
155 117 -
156 118 @endif
... ... @@ -185,7 +147,7 @@
185 147 </div>
186 148  
187 149 <div class="grid px-4 py-3 text-xs font-semibold tracking-wide text-gray-500 uppercase border-t dark:border-gray-700 bg-gray-50 sm:grid-cols-9 dark:text-gray-400 dark:bg-gray-800">
188   - <?//=$users->appends($_GET)->links('admin.pagginate'); ?>
  150 +
189 151 <?=$users->links('admin.pagginate'); ?>
190 152 </div>
191 153  
... ... @@ -288,7 +250,7 @@
288 250 </div>-->
289 251 </div>
290 252  
291   - <?//=$users->appends($_GET)->links('catalogs.paginate'); ?>
  253 +
292 254  
293 255  
294 256 @endsection
resources/views/employers/bd.blade.php
... ... @@ -139,10 +139,6 @@
139 139 </span>
140 140 </div>
141 141 <div class="table table_spoiler">
142   - <!--<button type="button" class="table__button js-toggle js-parent-toggle button button_light button_more">
143   - <span>Показать ещё</span>
144   - <span>Свернуть</span>
145   - </button>-->
146 142  
147 143 <div class="table__scroll">
148 144 <div class="table__body table__body_min-width">
... ... @@ -165,7 +161,16 @@
165 161 <tr>
166 162 <td>{{ $it->surname." ".$it->name_man }}<br>{{ $it->surname2 }}</td>
167 163  
168   - <td>{{ $it->jobtitles[0]->name ?? '-' }}</td>
  164 + <td>
  165 + @if($it->workers[0]->positions_work)
  166 + @foreach($it->workers[0]->jobs as $job)
  167 + {{ $job->name }}
  168 + @if(!$loop->last)
  169 + <br>
  170 + @endif
  171 + @endforeach
  172 + @endif
  173 + </td>
169 174  
170 175 <td>
171 176 @if (isset($it->workers[0]->id))
resources/views/layout/admin.blade.php
... ... @@ -26,6 +26,8 @@
26 26 <link rel="stylesheet" href="{{ asset('css/helpers.css') }}">
27 27 <link rel="stylesheet" href="{{ asset('css/jquery.fancybox.css') }}">
28 28 <link rel="stylesheet" href="{{ asset('css/general.css') }}">
  29 + <link rel="stylesheet" href="{{ asset('js/chosen/chosen.min.css') }}">
  30 + <script src="{{ asset('js/chosen/chosen.jquery.min.js') }}"></script>
29 31 </head>
30 32 <body>
31 33 <div class="flex h-screen bg-gray-50 dark:bg-gray-900" :class="{ 'overflow-hidden': isSideMenuOpen }">