Commit 468369903bf7b3341e4e8b92fe9568a190762aae

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

Изменение структуры проекта по вакансиям - кабинет работодателя

Showing 4 changed files with 106 additions and 77 deletions Side-by-side Diff

app/Http/Controllers/EmployerController.php
... ... @@ -163,13 +163,12 @@ class EmployerController extends Controller
163 163 $id = Auth()->user()->id;
164 164  
165 165 $categories = Category::query()->active()->get();
166   -
167   - if ($categories->count()) {
168   - $jobs = Job_title::query()->OrderBy('name')->where('is_remove', '=', '0')->Notbdif()->where('position_id', $categories[0]->id)->get();
169   - } else {
170   - $jobs = Job_title::query()->OrderBy('name')->where('is_remove', '=', '0')->Notbdif()->where('position_id', 0)->get();
171   - }
172   -
  166 + //if ($categories->count()) {
  167 + // $jobs = Job_title::query()->OrderBy('name')->where('is_remove', '=', '0')->Notbdif()->where('position_id', $categories[0]->id)->get();
  168 + //} else {
  169 + // $jobs = Job_title::query()->OrderBy('name')->where('is_remove', '=', '0')->Notbdif()->where('position_id', 0)->get();
  170 + //}
  171 + $jobs = Job_title::query()->OrderBy('name')->where('is_remove', '=', '0')->Notbdif()->get();
173 172 $Employer = Employer::query()->with('users')->with('ads')->with('flots')->
174 173 WhereHas('users',
175 174 function (Builder $query) use ($id) {$query->Where('id', $id);
... ... @@ -180,19 +179,22 @@ class EmployerController extends Controller
180 179 // Сохранение вакансии
181 180 public function cabinet_vacancy_save1(VacancyRequestEdit $request) {
182 181 $params_emp = $request->all();
  182 +
183 183 $params_job["job_title_id"] = $params_emp['job_title_id'];
184   - $params_job["min_salary"] = $params_emp['min_salary'];
185   - $params_job["max_salary"] = $params_emp['max_salary'];
186   - $params_job["region"] = $params_emp['region'];
187   - $params_job["power"] = $params_emp['power'];
188   - $params_job["sytki"] = $params_emp['sytki'];
189   - $params_job["start"] = $params_emp['start'];
190   - $params_job["flot"] = $params_emp['flot'];
  184 + //$params_job["min_salary"] = $params_emp['min_salary'];
  185 + //$params_job["max_salary"] = $params_emp['max_salary'];
  186 + //$params_job["region"] = $params_emp['region'];
  187 + //$params_job["power"] = $params_emp['power'];
  188 + //$params_job["sytki"] = $params_emp['sytki'];
  189 + //$params_job["start"] = $params_emp['start'];
  190 + //$params_job["flot"] = $params_emp['flot'];
191 191 $params_job["description"] = $params_emp['description'];
192 192  
193 193 $ad_jobs = Ad_employer::create($params_emp);
194   - $params_job['ad_employer_id'] = $ad_jobs->id;
195   - Ad_jobs::create($params_job);
  194 + //$params_job['ad_employer_id'] = $ad_jobs->id;
  195 + //Ad_jobs::create($params_job);
  196 + $ad_jobs->jobs()->sync($request->get('job_title_id'));
  197 +
196 198 return redirect()->route('employer.vacancy_list');
197 199 }
198 200  
app/Http/Controllers/WorkerController.php
... ... @@ -278,9 +278,6 @@ class WorkerController extends Controller
278 278 $persent = $persent + 5;
279 279 $persent5 = 5;
280 280 }
281   -
282   - //dd($persent1, $persent2, $persent3, $persent4, $persent5);
283   -
284 281 if ($request->has('print')) {
285 282 dd($Worker);
286 283 } else {
app/Models/Ad_employer.php
... ... @@ -68,4 +68,9 @@ class Ad_employer extends Model
68 68 public function ad_job() {
69 69 return $this->hasMany(Ad_jobs::class);
70 70 }
  71 +
  72 + // Связь Вакансии с должностями (0-0 - 1)
  73 + public function job_titles() {
  74 + return $this->belongsToMany(Job_title::class, 'title_workers');
  75 + }
71 76 }
resources/views/employers/add_vacancy.blade.php
... ... @@ -122,29 +122,28 @@
122 122 @enderror
123 123 </div>
124 124 </div>
125   -
126   - <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group">
  125 + <!--<div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group">
127 126 <label class="form-group__label">Категория (локация)</label>
128 127 <div class="form-group__item">
129 128 <div class="select">
130 129 <select class="js-select2" name="category_id" id="category_id">
131 130 <option selected> Выберите категорию из списка</option>
132   - @php $i = 1 @endphp
133   - @if ($categories->count())
134   - @foreach($categories as $j)
135   - <option value="{{ $j->id }}">{{ $j->name }}</option>
136   - @php $i++ @endphp
137   - @endforeach
138   - @endif
  131 + _php $i = 1 _endphp
  132 + _if ($categories->count())
  133 + _foreach($categories as $j)
  134 + <option value=" $j->id }}"> $j->name }}</option>
  135 + _php $i++ _endphp
  136 + _endforeach
  137 + _endif
139 138 </select>
140   - @error('category_id')
  139 + _error('category_id')
141 140 <span class="text-xs text-red-600 dark:text-red-400">
142   - {{ $message }}
  141 + $message }}
143 142 </span>
144   - @enderror
  143 + _enderror
145 144 </div>
146 145 </div>
147   - </div>
  146 + </div>-->
148 147  
149 148 <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group">
150 149 <label class="form-group__label">Описание вакансии</label>
... ... @@ -167,100 +166,126 @@
167 166 </div>
168 167 </div>
169 168  
170   - <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group">
  169 + <!--<div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group">
171 170 <label class="form-group__label">Должность соискателя</label>
172 171 <div class="form-group__item">
173 172 <div class="select">
174 173 <select class="js-select2" name="job_title_id" id="job_title_id">
  174 + php $i = 1 endphp
  175 + if ($jobs->count())
  176 + foreach($jobs as $j)
  177 + if ($i == 1) <option selected> Выберите должность из списка</option>
  178 + else
  179 + <option value=" $j->id }}"> $j->name }}</option>
  180 + endif
  181 + php $i++ endphp
  182 + endforeach
  183 + endif
  184 + </select>
  185 + error('job_title_id')
  186 + <span class="text-xs text-red-600 dark:text-red-400">
  187 + $message }}
  188 + </span>
  189 + enderror
  190 + </div>
  191 + </div>
  192 + </div>-->
  193 +
  194 + <div class="cabinet__inputs-item cabinet__inputs-item_max form-group">
  195 + <label class="form-group__label">Добавление должностей</label>
  196 + <div class="form-group__item">
  197 + <div class="select">
  198 + <select class="js-select2" name="job_title_id[]" id="job_title_id[]" multiple="multiple">
175 199 @php $i = 1 @endphp
176 200 @if ($jobs->count())
177   - @foreach($jobs as $j)
178   - @if ($i == 1) <option selected> Выберите должность из списка</option>
179   - @else
180   - <option value="{{ $j->id }}">{{ $j->name }}</option>
  201 + @foreach($jobs as $it)
  202 + @php $selected = false; @endphp
  203 + @if (isset($Worker[0]->job_titles))
  204 + @if ($Worker[0]->job_titles->count())
  205 + @foreach($Worker[0]->job_titles as $select)
  206 + @if ($it->id == $select->id)
  207 + @php $selected = true; @endphp
  208 + @endif
  209 + @endforeach
  210 + @endif
181 211 @endif
182   - @php $i++ @endphp
  212 + <option value="{{ $it->id }}" @if ($selected) selected @endif>{{ $it->name }}</option>
183 213 @endforeach
184 214 @endif
185 215 </select>
186   - @error('job_title_id')
187   - <span class="text-xs text-red-600 dark:text-red-400">
188   - {{ $message }}
189   - </span>
190   - @enderror
191 216 </div>
192 217 </div>
193 218 </div>
194 219  
195   - <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group">
  220 + <!--<div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group">
196 221 <label class="form-group__label">Минимальная зарплата</label>
197 222 <div class="form-group__item">
198   - <input type="text" class="input" name="min_salary" id="min_salary" value="{{ old('min_salary') ?? '' }}" placeholder="Минимальная зарплата">
199   - @error('min_salary')
  223 + <input type="text" class="input" name="min_salary" id="min_salary" value=" old('min_salary') ?? '' }}" placeholder="Минимальная зарплата">
  224 + error('min_salary')
200 225 <span class="text-xs text-red-600">
201   - {{ $message }}
  226 + $message }}
202 227 </span>
203   - @enderror
  228 + enderror
204 229 </div>
205 230 </div>
206 231  
207 232 <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group">
208 233 <label class="form-group__label">Максимальная зарплата</label>
209 234 <div class="form-group__item">
210   - <input type="text" class="input" name="max_salary" id="max_salary" value="{{ old('max_salary') ?? '' }}" placeholder="Максимальная зарплата">
211   - @error('salary')
  235 + <input type="text" class="input" name="max_salary" id="max_salary" value=" old('max_salary') ?? '' }}" placeholder="Максимальная зарплата">
  236 + error('salary')
212 237 <span class="text-xs text-red-600 dark:text-red-400">
213   - {{ $message }}
  238 + $message }}
214 239 </span>
215   - @enderror
  240 + enderror
216 241 </div>
217 242 </div>
218 243  
219 244 <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group">
220 245 <label class="form-group__label">Регион отплытия</label>
221 246 <div class="form-group__item">
222   - <input type="text" class="input" name="region" id="region" value="{{ old('region') ?? $Employer[0]->city ?? '' }}" placeholder="Севастополь">
223   - @error('region')
  247 + <input type="text" class="input" name="region" id="region" value=" old('region') ?? $Employer[0]->city ?? '' }}" placeholder="Севастополь">
  248 + error('region')
224 249 <span class="text-xs text-red-600">
225   - {{ $message }}
  250 + $message }}
226 251 </span>
227   - @enderror
  252 + enderror
228 253 </div>
229 254 </div>
230 255  
231 256 <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group">
232 257 <label class="form-group__label">Мощность</label>
233 258 <div class="form-group__item">
234   - <input type="text" class="input" name="power" id="power" value="{{ old('power') ?? '' }}" placeholder="POWER-45">
235   - @error('power')
  259 + <input type="text" class="input" name="power" id="power" value=" old('power') ?? '' }}" placeholder="POWER-45">
  260 + error('power')
236 261 <span class="text-xs text-red-600">
237   - {{ $message }}
  262 + $message }}
238 263 </span>
239   - @enderror
  264 + enderror
240 265 </div>
241 266 </div>
242 267  
243 268 <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group">
244 269 <label class="form-group__label">Суточные выплаты</label>
245 270 <div class="form-group__item">
246   - <input type="text" class="input" name="sytki" id="sytki" value="{{ old('sytki') ?? '' }}" placeholder="2000">
247   - @error('power')
  271 + <input type="text" class="input" name="sytki" id="sytki" value=" old('sytki') ?? '' }}" placeholder="2000">
  272 + error('power')
248 273 <span class="text-xs text-red-600">
249   - {{ $message }}
  274 + $message }}
250 275 </span>
251   - @enderror
  276 + enderror
252 277 </div>
253 278 </div>
254 279  
255 280 <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group">
256 281 <label class="form-group__label">Начало отплытия</label>
257 282 <div class="form-group__item">
258   - <input type="text" class="input" name="start" id="start" value="{{ old('start') ?? '' }}" placeholder="20 сентября 2024">
259   - @error('power')
  283 + <input type="text" class="input" name="start" id="start" value=" old('start') ?? '' }}" placeholder="20 сентября 2024">
  284 + error('power')
260 285 <span class="text-xs text-red-600">
261   - {{ $message }}
  286 + $message }}
262 287 </span>
263   - @enderror
  288 + enderror
264 289 </div>
265 290 </div>
266 291  
... ... @@ -270,20 +295,20 @@
270 295 <div class="select">
271 296 <select class="js-select2" name="flot" id="flot">
272 297 <option value="" selected> Не указан корабль</option>
273   - @if ($Employer[0]->flots->count())
274   - @foreach($Employer[0]->flots as $j)
275   - <option value="{{ $j->name }}">{{ $j->name }} ({{ $j->id }})</option>
276   - @endforeach
277   - @endif
  298 + if ($Employer[0]->flots->count())
  299 + foreach($Employer[0]->flots as $j)
  300 + <option value=" $j->name }}"> $j->name }} ( $j->id }})</option>
  301 + endforeach
  302 + endif
278 303 </select>
279   - @error('flot')
  304 + error('flot')
280 305 <span class="text-xs text-red-600">
281   - {{ $message }}
  306 + $message }}
282 307 </span>
283   - @enderror
  308 + enderror
284 309 </div>
285 310 </div>
286   - </div>
  311 + </div>-->
287 312  
288 313 <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group">
289 314 <label class="form-group__label">Дополнительная информация</label>