From 2b8dd10cb31d530c6871efb1d3bd5a212141f005 Mon Sep 17 00:00:00 2001 From: Sergey Panarin Date: Sun, 11 Aug 2024 17:01:23 +0200 Subject: [PATCH] =?UTF-8?q?=D0=9F=D1=80=D0=B0=D0=B2=D0=BA=D0=B8=20=D0=BF=D0=BE?= =?UTF-8?q?=20=D0=B7=D0=B0=D0=B4=D0=B0=D1=87=D0=B0=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Admin/UsersController.php | 10 ++-- app/Http/Controllers/EmployerController.php | 9 ++-- app/Models/Worker.php | 29 ++++++++++ .../2024_08_10_123217_alter_table_workers.php | 34 ++++++++++++ public/js/chosen/chosen-sprite.png | Bin 0 -> 538 bytes public/js/chosen/chosen-sprite@2x.png | Bin 0 -> 738 bytes resources/views/admin/users/form.blade.php | 39 +++++++------- resources/views/admin/users/index_bd.blade.php | 56 ++++---------------- resources/views/employers/bd.blade.php | 15 ++++-- resources/views/layout/admin.blade.php | 2 + 10 files changed, 114 insertions(+), 80 deletions(-) create mode 100644 database/migrations/2024_08_10_123217_alter_table_workers.php create mode 100644 public/js/chosen/chosen-sprite.png create mode 100644 public/js/chosen/chosen-sprite@2x.png diff --git a/app/Http/Controllers/Admin/UsersController.php b/app/Http/Controllers/Admin/UsersController.php index ebacd2f..98da7ff 100644 --- a/app/Http/Controllers/Admin/UsersController.php +++ b/app/Http/Controllers/Admin/UsersController.php @@ -81,7 +81,7 @@ class UsersController extends Controller public function add_store_bd(BaseUserRequest $request) { $params = $request->all(); - $position_work = $request->position_work; + $positions_work = json_encode($request->input('positions_work', [])); if ($request->has('file')) { $params['file'] = $request->file('file')->store('basedata', 'public'); @@ -94,7 +94,7 @@ class UsersController extends Controller $user = User::create($params); $user_id = $user->id; $worker = new Worker(); - $worker->position_work = $position_work; + $worker->positions_work = $positions_work; $worker->user_id = $user_id; $worker->save(); @@ -109,7 +109,7 @@ class UsersController extends Controller public function update_bd(BaseUserRequest $request, User $user) { $params = $request->all(); - $position_work = $request->position_work; + $positions_work = $request->input('positions_work', []); if ($request->has('file')) { if (!empty($user->file)) Storage::delete($user->file); @@ -125,12 +125,12 @@ class UsersController extends Controller $user->update($params); if (isset($user->workers[0]->id)) { $worker = Worker::find($user->workers[0]->id); - $worker->position_work = $position_work; + $worker->positions_work = $positions_work; $worker->save(); } else { $worker = new Worker(); $worker->user_id = $user->id; - $worker->position_work = $position_work; + $worker->positions_work = $positions_work; $worker->save(); } diff --git a/app/Http/Controllers/EmployerController.php b/app/Http/Controllers/EmployerController.php index 355a7d2..1be6f86 100644 --- a/app/Http/Controllers/EmployerController.php +++ b/app/Http/Controllers/EmployerController.php @@ -208,9 +208,12 @@ class EmployerController extends Controller //dd($request->all()); $Employer = Employer::query()->where('user_id', $id)->first(); - $vacancy_list = Ad_employer::query()->with('jobs')-> - with('jobs_code')-> - where('employer_id', $Employer->id); + $vacancy_list = Ad_employer::query() + ->with('jobs') + ->with('jobs_code') + ->where('employer_id', $Employer->id) + ->where('is_remove', 0) + ; if (($request->has('search')) && (!empty($request->get('search')))) { $search = $request->get('search'); diff --git a/app/Models/Worker.php b/app/Models/Worker.php index 2806a46..03892e5 100644 --- a/app/Models/Worker.php +++ b/app/Models/Worker.php @@ -15,6 +15,7 @@ class Worker extends Model 'user_id', 'status_work', 'position_work', + 'positions_work', 'telephone', 'telephone2', 'persent_anketa', @@ -56,6 +57,28 @@ class Worker extends Model 'military_id_available' ]; + /** + * Получить значение поля positions_work как массив. + * + * @param string $value + * @return array + */ + public function getPositionsWorkAttribute($value) + { + return json_decode($value, true); + } + + /** + * Установить значение поля positions_work как JSON. + * + * @param array|string $value + * @return void + */ + public function setPositionsWorkAttribute($value) + { + $this->attributes['positions_work'] = is_array($value) ? json_encode($value) : $value; + } + /* * Связь таблицы users с таблицей workers */ @@ -101,4 +124,10 @@ class Worker extends Model return $this->hasMany(ResponseWork::class); } + public function getJobsAttribute() + { + $job_titles_ids = json_decode($this->attributes['positions_work'], true); + return Job_title::whereIn('id', $job_titles_ids)->get(); + } + } diff --git a/database/migrations/2024_08_10_123217_alter_table_workers.php b/database/migrations/2024_08_10_123217_alter_table_workers.php new file mode 100644 index 0000000..7ccb59a --- /dev/null +++ b/database/migrations/2024_08_10_123217_alter_table_workers.php @@ -0,0 +1,34 @@ +string('positions_work', 255)->nullable(true)->after('position_work'); + $table->integer('position_work')->nullable(true)->change(); + + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('workers', function (Blueprint $table) { + $table->dropColumn('positions_work'); + }); + } +}; diff --git a/public/js/chosen/chosen-sprite.png b/public/js/chosen/chosen-sprite.png new file mode 100644 index 0000000000000000000000000000000000000000..c57da70b4b5b1e08a6977ddde182677af0e5e1b8 GIT binary patch literal 538 zcmV+#0_FXQP)cz2)-WJLkv8J@4bb5L`rsE?Kc|FrXHkKz)ov z76MHYM&Apx%05P7orE!>9=yZ~6O0^V?1%{=1UASqa<2Pgnk7fs!OIs9gh{NCN+@=) z>Gfttd5uq;oeR{%NHjtqV~jEQeY?tDff=(jqx>~SZ_e+iN26HR*`0Q!Re)~HD85p> zbL()Mw}bI^#`7wp0+cv&7*LhrtOmR)?PK>(-BeLm#jL5Jfogv-QS(TBnUb;))Krqm zD}uDDeVLNhm1G*pFB`O?iA=dnWBEpqHk8Yh%Qu45EIG=&F-dDmt|;|nN@|3lOkVZ7>z*~a1?_t?U)c+&|JFJke1`&0-a z#PjhRlg?=$KTo4|rU@NyV_fzDy@>h!lVyKShsO8>V>$xyIXRbHK%H~^Aaz=s$Jz^V zlb?KfaKdZqu3^#m$mintvgJ15@j`sb2Zr%69Sn=xN01Tm5r)NQanT=jhwm7zqj2>O cEB}D~0$b-QdD7|v=>Px#07*qoM6N<$g6AXnUH||9 literal 0 HcmV?d00001 diff --git a/public/js/chosen/chosen-sprite@2x.png b/public/js/chosen/chosen-sprite@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..6b50545202cb4770039362c55025b0b9824663ad GIT binary patch literal 738 zcmV<80v-K{P)oJoIWh{eAG@xkM<0ryd(K3(} zP8JV&;uuIJ4nL%g8!wSG9E$P+3QVMGgj><+00}M5I5kMzaT<~M;uJ`UhLfbp9Ahdsrux5(g+(>Q*+9wU{AuYPH0}W_u4`|q(9c->{ zt>Jn|lbhH<_x5jU6prFi#S}&XMZ=~Y5VyC3+ZN%hXciz8 zPcLpJgbIK#a49e31-%wf2zh2F&&(Nq;AL%4zA(=QJRGq`sx3y3#0_cg9Fim739XTOu1NKKjlWs`52Q+3 Uja*K~(*OVf07*qoM6N<$g3mu-GXMYp literal 0 HcmV?d00001 diff --git a/resources/views/admin/users/form.blade.php b/resources/views/admin/users/form.blade.php index 7abcce7..7955aa9 100644 --- a/resources/views/admin/users/form.blade.php +++ b/resources/views/admin/users/form.blade.php @@ -1,16 +1,7 @@
- + @error('name') + {{ $message }} + @enderror Должность - @isset($list_job_titles) @foreach($list_job_titles as $job_title) + @if (in_array($job_title->id , $user->workers[0]->positions_work)) + selected + @endif + > + {{ $job_title->name }} ({{ $job_title->id }}) + @endforeach @endisset @@ -148,3 +138,12 @@
+ + diff --git a/resources/views/admin/users/index_bd.blade.php b/resources/views/admin/users/index_bd.blade.php index a0a6464..cc8e6ea 100644 --- a/resources/views/admin/users/index_bd.blade.php +++ b/resources/views/admin/users/index_bd.blade.php @@ -91,34 +91,11 @@ {{$user->id}} - - - {{ $user->name }}
-

{{ empty($user->employers->email) ? $user->email : $user->employers->email }}

@@ -128,29 +105,14 @@

- - - @if (isset($user->jobtitles[0]->name)) - {{ $user->jobtitles[0]->name }} + @if (isset($user->workers[0]->positions_work)) + @foreach($user->workers[0]->jobs as $job) + {{ $job->name }} + @if(!$loop->last) +
+ @endif + @endforeach @else - @endif @@ -185,7 +147,7 @@
- appends($_GET)->links('admin.pagginate'); ?> + links('admin.pagginate'); ?>
@@ -288,7 +250,7 @@ --> - appends($_GET)->links('catalogs.paginate'); ?> + @endsection diff --git a/resources/views/employers/bd.blade.php b/resources/views/employers/bd.blade.php index d2ac597..f45606b 100644 --- a/resources/views/employers/bd.blade.php +++ b/resources/views/employers/bd.blade.php @@ -139,10 +139,6 @@
-
@@ -165,7 +161,16 @@ {{ $it->surname." ".$it->name_man }}
{{ $it->surname2 }} - {{ $it->jobtitles[0]->name ?? '-' }} + + @if($it->workers[0]->positions_work) + @foreach($it->workers[0]->jobs as $job) + {{ $job->name }} + @if(!$loop->last) +
+ @endif + @endforeach + @endif + @if (isset($it->workers[0]->id)) diff --git a/resources/views/layout/admin.blade.php b/resources/views/layout/admin.blade.php index 8d65ab1..910ae4a 100644 --- a/resources/views/layout/admin.blade.php +++ b/resources/views/layout/admin.blade.php @@ -26,6 +26,8 @@ + +
-- 1.7.10.4