Commit d76ea6dbb8025f93a3f5244c0a4700227ea35c5a

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

Обновление2

Showing 8 changed files with 47 additions and 66 deletions Side-by-side Diff

app/Http/Controllers/Ad_jobsController.php
... ... @@ -43,7 +43,7 @@ class Ad_jobsController extends Controller
43 43 public function add_job_in_vac(Request $request, Ad_employer $ad_employer) {
44 44 $id = Auth()->user()->id;
45 45  
46   - $Positions = Positions::query()->get();
  46 + $Positions = Category::query()->get();
47 47 if ($Positions->count()) {
48 48 $jobs = Job_title::query()->OrderBy('name')->where('position_id', $Positions[0]->id)->get();
49 49 } else {
... ... @@ -65,22 +65,25 @@ class Ad_jobsController extends Controller
65 65 return redirect()->route('employer.vacancy_list');
66 66 }
67 67  
68   - public function edit_job_in_vac(Ad_jobs $ad_job, Ad_employer $ad_employer) {
  68 + public function edit_job_in_vac(Ad_jobs $ad_job, Ad_employer $ad_employer, Request $request) {
69 69 $id = Auth()->user()->id;
  70 + if ($request->has('job_title_id'))
  71 + $job_title_id= $request->get('job_title_id');
  72 + else
  73 + $job_title_id = '';
70 74  
71   - $Positions = Positions::query()->get();
  75 + $Positions = Category::query()->get();
72 76 if ($Positions->count()) {
73   - $jobs = Job_title::query()->OrderBy('name')->where('position_id', $Positions[0]->id)->get();
  77 + $jobs123 = Job_title::query()->OrderBy('name')->where('position_id', $ad_job->job_title->position_id )->get();
74 78 } else {
75   - $jobs = Job_title::query()->OrderBy('name')->where('position_id', 0)->get();
  79 + $jobs123 = Job_title::query()->OrderBy('name')->where('position_id', 0)->get();
76 80 }
77   - $categories = Category::query()->get();
  81 +
78 82 $Employer = Employer::query()->with('users')->with('ads')->with('flots')->
79 83 where('user_id', $id)->first();
80   -
81 84 return view('employers.edit_ad_jobs', compact('ad_job',
82   - 'Positions', 'categories',
83   - 'Employer','jobs', 'ad_employer'));
  85 + 'Positions',
  86 + 'Employer','jobs123', 'ad_employer', 'job_title_id'));
84 87 }
85 88  
86 89 public function edit_job_in_vac_save(Request $request, Ad_jobs $ad_job) {
app/Http/Controllers/Admin/JobTitlesController.php
... ... @@ -4,6 +4,7 @@ namespace App\Http\Controllers\Admin;
4 4  
5 5 use App\Http\Controllers\Controller;
6 6 use App\Http\Requests\JobTitlesRequest;
  7 +use App\Models\Category;
7 8 use App\Models\Job_title;
8 9 use App\Models\Positions;
9 10 use Illuminate\Http\Request;
... ... @@ -33,9 +34,9 @@ class JobTitlesController extends Controller
33 34 orderBy('name')->
34 35 active()->
35 36 get();*/
36   - $position = Positions::query()->get();
  37 + $category = Category::query()->get();
37 38  
38   - return view('admin.job_titles.add', compact('position'));
  39 + return view('admin.job_titles.add', compact('category'));
39 40 }
40 41  
41 42 /**
... ... @@ -69,8 +70,8 @@ class JobTitlesController extends Controller
69 70 */
70 71 public function edit(Job_title $job_title)
71 72 {
72   - $position = Positions::query()->get();
73   - return view('admin.job_titles.edit', compact('job_title', 'position'));
  73 + $category = Category::query()->get();
  74 + return view('admin.job_titles.edit', compact('job_title', 'category'));
74 75 }
75 76  
76 77 /**
app/Models/Ad_jobs.php
... ... @@ -22,7 +22,8 @@ class Ad_jobs extends Model
22 22 'sytki',
23 23 'start',
24 24 'description',
25   - 'position_ship'
  25 + 'position_ship',
  26 + 'power'
26 27 ];
27 28  
28 29 public function job_title() {
... ... @@ -32,4 +33,8 @@ class Ad_jobs extends Model
32 33 public function positions() {
33 34 return $this->belongsToMany(Positions::class, 'job_titles');
34 35 }
  36 +
  37 + public function categoria() {
  38 + return $this->belongsToMany(Category::class, 'job_titles', 'id', 'position_id');
  39 + }
35 40 }
resources/views/admin/job_titles/form.blade.php
... ... @@ -26,16 +26,16 @@
26 26 </label><br>
27 27  
28 28 <label class="block text-sm">
29   - <span class="text-gray-700 dark:text-gray-400">Папка</span>
  29 + <span class="text-gray-700 dark:text-gray-400">Категория должности</span>
30 30  
31 31 @php
32   - $position_id = old('position_id') ?? $job_title->position_id ?? 0;
  32 + $category_id = old('position_id') ?? $job_title->position_id ?? 0;
33 33 @endphp
34 34 <select name="position_id" 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"
35 35 title="Родитель">
36 36 <option value="">Без родителя</option>
37   - @foreach ($position as $it)
38   - <option value="{{ $it->id }}" @if ($it->id == $position_id) selected @endif>{{ $it->name }}</option>
  37 + @foreach ($category as $it)
  38 + <option value="{{ $it->id }}" @if ($it->id == $category_id) selected @endif>{{ $it->name }}</option>
39 39 @endforeach
40 40 </select>
41 41 </label><br>
resources/views/employers/add_ad_jobs.blade.php
... ... @@ -60,7 +60,7 @@
60 60 </div>
61 61  
62 62 <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group">
63   - <label class="form-group__label">Позиция на корабле</label>
  63 + <label class="form-group__label">Категория вакансии</label>
64 64 <div class="form-group__item">
65 65 <div class="select">
66 66 <select class="js-select2" name="position_id" id="position_id">
... ... @@ -103,31 +103,6 @@
103 103 </div>
104 104  
105 105 <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group">
106   - <label class="form-group__label">Категория (локация)</label>
107   - <div class="form-group__item">
108   - <div class="select">
109   - <select class="js-select2" name="category_id" id="category_id">
110   - @php $i = 1 @endphp
111   - @if ($categories->count())
112   - @foreach($categories as $j)
113   - @if ($i == 1) <option selected> Выберите категорию из списка</option>
114   - @else
115   - <option value="{{ $j->id }}">{{ $j->name }}</option>
116   - @endif
117   - @php $i++ @endphp
118   - @endforeach
119   - @endif
120   - </select>
121   - @error('category_id')
122   - <span class="text-xs text-red-600 dark:text-red-400">
123   - {{ $message }}
124   - </span>
125   - @enderror
126   - </div>
127   - </div>
128   - </div>
129   -
130   - <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group">
131 106 <label class="form-group__label">Минимальная зарплата</label>
132 107 <div class="form-group__item">
133 108 <input type="text" class="input" name="min_salary" id="min_salary" value="{{ old('min_salary') ?? '' }}" placeholder="Минимальная зарплата">
resources/views/employers/edit_ad_jobs.blade.php
... ... @@ -60,12 +60,12 @@
60 60 </div>
61 61  
62 62 <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group">
63   - <label class="form-group__label">Позиция на корабле</label>
  63 + <label class="form-group__label">Категория должности</label>
64 64 <div class="form-group__item">
65 65 <div class="select">
66 66 <select class="js-select2" name="position_id" id="position_id">
67 67 @foreach ($Positions as $it)
68   - <option value="{{ $it->id }}">{{ $it->name }}</option>
  68 + <option value="{{ $it->id }}" @if (isset($ad_job->job_title)) @if($ad_job->job_title->position_id == $it->id) selected @endif @endif>{{ $it->name }}</option>
69 69 @endforeach
70 70 </select>
71 71 @error('postion_id')
... ... @@ -82,16 +82,13 @@
82 82 <div class="form-group__item">
83 83 <div class="select">
84 84 <select class="js-select2" name="job_title_id" id="job_title_id">
85   - @php $i = 1 @endphp
86   - @if ($jobs->count())
87   - @foreach($jobs as $j)
88   - @if ($i == 1) <option selected> Выберите должность из списка</option>
89   - @else
90   - <option value="{{ $j->id }}">{{ $j->name }}</option>
91   - @endif
92   - @php $i++ @endphp
  85 + @php $i = 1;
  86 + @endphp
  87 + <option value="0"> Выберите должность из списка</option>
  88 + @foreach($jobs123 as $j)
  89 + <option value="{{ $j->id }}" @if ($job_title_id == $j->id) selected @endif>{{ $j->name }}</option>
  90 + @php $i++ @endphp
93 91 @endforeach
94   - @endif
95 92 </select>
96 93 @error('job_title_id')
97 94 <span class="text-xs text-red-600 dark:text-red-400">
resources/views/employers/list_vacancy.blade.php
... ... @@ -99,13 +99,13 @@
99 99 <td>{{ $it->name }}</td>
100 100 <td>{{ date('d.m.Y H:i:s', strtotime($it->created_at)) }} <br>/ {{ date('d.m.Y H:i:s', strtotime($it->updated_at)) }}</td>
101 101 <td> <a href="{{ route('employer.add_job_in_vac', ['ad_employer' => $it->id]) }}" class="button">Добавить</a>
102   - @if ($it->jobs->count())
103 102  
  103 + @if ($it->jobs->count())
104 104 @foreach ($it->jobs as $key => $it_um)
105   - <p><a href="{{ route('employer.edit_job_in_vac', ['ad_job' => $it_um->id, 'ad_employer' => $it->id]) }}" style="text-decoration: underline">{{$it_um->name}}</a>
106   - @if (isset($it->jobs_code[$key]))
107   - <a href="{{ route('employer.delete_job_in_vac', ['ad_job' => $it->jobs_code[$key]->id]) }}" style="text-decoration: underline">(Del)</a>
108   - @endif
  105 + <p>@if (isset($it->jobs_code[$key]))
  106 + <a href="{{ route('employer.edit_job_in_vac', ['ad_job' => $it->jobs_code[$key]->id, 'ad_employer' => $it->id, 'job_title_id' => $it_um->id]) }}" style="text-decoration: underline">{{$it_um->name}}</a>
  107 + <a href="{{ route('employer.delete_job_in_vac', ['ad_job' => $it->jobs_code[$key]->id]) }}" style="text-decoration: underline">(Del)</a>
  108 + @endif
109 109 </p>
110 110 @endforeach
111 111 @else
resources/views/layout/admin.blade.php
... ... @@ -571,9 +571,9 @@
571 571 @endif
572 572 @endif
573 573 @endforeach
574   - <li class="px-2 py-1 transition-colors duration-150 hover:text-gray-800 dark:hover:text-gray-200 {{ Request::routeIs('admin.position') ? 'dark:text-gray-100' : null }}">
575   - <a class="w-full" href="{{ route('admin.position') }}">Позиция</a>
576   - </li>
  574 + <!--<li class="px-2 py-1 transition-colors duration-150 hover:text-gray-800 dark:hover:text-gray-200 {{ Request::routeIs('admin.position') ? 'dark:text-gray-100' : null }}">
  575 + <a class="w-full" href=" route('admin.position') }}">Позиция</a>
  576 + </li>-->
577 577 </ul>
578 578 </template>
579 579 </li>
... ... @@ -1234,9 +1234,9 @@
1234 1234 @if ($cont->url_page == "admin/position")
1235 1235 @if ((($cont->is_admin == 1) && ($admin == 1)) ||
1236 1236 (($cont->is_manager == 1) && ($is_manager == 1)))
1237   - <li class="px-2 py-1 transition-colors duration-150 hover:text-gray-800 dark:hover:text-gray-200 {{ Request::routeIs('admin.position') ? 'dark:text-gray-100' : null }}">
1238   - <a class="w-full" href="{{ route('admin.position') }}">Позиция</a>
1239   - </li>
  1237 + <!--<li class="px-2 py-1 transition-colors duration-150 hover:text-gray-800 dark:hover:text-gray-200 {{ Request::routeIs('admin.position') ? 'dark:text-gray-100' : null }}">
  1238 + <a class="w-full" href=" route('admin.position') }}">Позиция</a>
  1239 + </li>-->
1240 1240 @endif
1241 1241 @endif
1242 1242