Commit c54cbb05e525c523064361c53f1f90c77ef67bcb

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

Коммит субботний

Showing 8 changed files with 102 additions and 44 deletions Side-by-side Diff

app/Http/Controllers/Admin/InfoBloksController.php
... ... @@ -15,7 +15,9 @@ class InfoBloksController extends Controller
15 15 */
16 16 public function index()
17 17 {
18   - $infobloks = infobloks::query()->active()->orderByDesc('sort')->orderBy('name')->paginate(15);
  18 + $infobloks = infobloks::query()->
  19 + //active()->
  20 + orderByDesc('sort')->orderBy('name')->paginate(15);
19 21 return view('admin.infobloks.index', compact('infobloks'));
20 22 }
21 23  
... ... @@ -84,7 +86,7 @@ class InfoBloksController extends Controller
84 86 */
85 87 public function destroy(infobloks $infoblok)
86 88 {
87   - $infoblok->update(['is_remove' => 1]);
  89 + $infoblok->delete(); // update(['is_remove' => 1]);
88 90 return redirect()->route('admin.infobloks.index');
89 91 }
90 92 }
app/Http/Controllers/Admin/UsersController.php
... ... @@ -45,6 +45,12 @@ class UsersController extends Controller
45 45 }
46 46 }
47 47  
  48 + public function user_delete(User $user) {
  49 + $id = $user->delete();
  50 +
  51 + return redirect()->route('admin.users')->with('Пользователь был удален из системы');
  52 + }
  53 +
48 54 public function index_bd(Request $request) {
49 55 $title = 'Админка - Пользователи базы данных';
50 56  
app/Http/Controllers/CompanyController.php
... ... @@ -2,6 +2,7 @@
2 2  
3 3 namespace App\Http\Controllers;
4 4  
  5 +use App\Models\Ad_employer;
5 6 use App\Models\Employer;
6 7 use Illuminate\Http\Request;
7 8  
... ... @@ -52,6 +53,10 @@ class CompanyController extends Controller
52 53  
53 54 $title = $company[0]->name_company;
54 55  
55   - return view('info_company_new', compact('company', 'user_id', 'title'));
  56 + $ads = Ad_employer::query()->with('jobs')->with('jobs_code')->
  57 + OrderByDesc('id')->
  58 + where('employer_id', '=', $company[0]->id)->paginate(2);
  59 +
  60 + return view('info_company_new', compact('company', 'user_id', 'title', 'ads'));
56 61 }
57 62 }
app/Http/Controllers/EmployerController.php
... ... @@ -164,18 +164,15 @@ class EmployerController extends Controller
164 164  
165 165 if (Auth()->user()->is_public) {
166 166 $categories = Category::query()->active()->get();
167   -
168 167 $jobs = Job_title::query()->orderByDesc('sort')->OrderBy('name')->
169 168 where('is_remove', '=', '0')->
170 169 where('is_bd', '=', '0')->
171 170 get();
172 171 $Employer = Employer::query()->with('users')->with('ads')->with('flots')->
173   -
174 172 WhereHas('users',
175 173 function (Builder $query) use ($id) {
176 174 $query->Where('id', $id);
177 175 })->get();
178   -
179 176 return view('employers.add_vacancy', compact('Employer', 'jobs', 'categories'));
180 177 } else {
181 178 return redirect()->route('employer.cabinet_vacancie_danger');
... ... @@ -249,18 +246,19 @@ class EmployerController extends Controller
249 246 public function vacancy_edit(Ad_employer $ad_employer) {
250 247 $id = Auth()->user()->id;
251 248 $Positions = Category::query()->where('is_remove', '=', '0')->get();
252   - $jobs = Job_title::query()->OrderBy('name')->
253   - where('is_remove', 0)->where('is_bd', '=' , '0')->get();
254   -
255   - $Employer = Employer::query()->with('users')->with('ads')->with('flots')->
256   - where('user_id', $id)->first();
  249 + $jobs = Job_title::query()->orderByDesc('sort')->OrderBy('name')->
  250 + where('is_remove', '=', '0')->
  251 + where('is_bd', '=', '0')->get();
257 252  
  253 + $Employer = Employer::query()->with('users')->with('ads')->
  254 + with('flots')->where('user_id', $id)->first();
258 255 return view('employers.edit_vacancy', compact('ad_employer', 'Positions','Employer', 'jobs'));
259 256 }
260 257  
261 258 // Сохранение-редактирование записи
262 259 public function vacancy_save_me(VacancyRequestEdit $request, Ad_employer $ad_employer) {
263 260 $params = $request->all();
  261 + $params_job["job_title_id"] = $params['job_title_id'];
264 262  
265 263 //$jobs['flot'] = $params['flot'];
266 264 //$jobs['job_title_id'] = $params['job_title_id'];
... ... @@ -268,6 +266,7 @@ class EmployerController extends Controller
268 266 //unset($params['job_title_id']);
269 267  
270 268 $ad_employer->update($params);
  269 + $ad_employer->jobs()->sync($request->get('job_title_id'));
271 270  
272 271 //$job_ = Ad_jobs::query()->where('job_title_id', $jobs['job_title_id'])->
273 272 // where('ad_employer_id', $ad_employer->id)->first();
resources/views/admin/users/index.blade.php
... ... @@ -62,6 +62,7 @@
62 62 <th class="px-4 py-3 text-xs">Админ</th>
63 63 <th class="px-4 py-3 text-xs">Менеджер</th>
64 64 <th class="px-4 py-3 text-xs">Дата регист.</th>
  65 + <th class="px-4 py-3 text-xs">Удаление</th>
65 66 </tr>
66 67 </thead>
67 68 <tbody class="bg-white divide-y dark:divide-gray-700 dark:bg-gray-800">
... ... @@ -111,6 +112,10 @@
111 112 <td class="px-4 py-3 text-xs">
112 113 {{ date('d.m.Y', strtotime($user->created_at)) }}
113 114 </td>
  115 +
  116 + <td class="px-4 py-3 text-xs">
  117 + <a href="{{ route('admin.user_delete', ['user' => $user->id]) }}">Del</a>
  118 + </td>
114 119 </tr>
115 120 @endforeach
116 121 </tbody>
resources/views/employers/edit_vacancy.blade.php
... ... @@ -110,10 +110,10 @@
110 110 </div>
111 111 </div>
112 112  
113   - <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group">
  113 + <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group" style="display: none">
114 114 <label class="form-group__label">Город посадки</label>
115 115 <div class="form-group__item">
116   - <input type="text" class="input" name="city" id="city" value="{{ old('city') ?? $ad_employer->city ?? '' }}" placeholder="Севастополь">
  116 + <input type="text" class="input" name="city" id="city" value="{{ old('city') ?? $ad_employer->city ?? 'Не указан' }}" placeholder="Севастополь">
117 117 @error('city')
118 118 <span class="text-xs text-red-600">
119 119 {{ $message }}
... ... @@ -146,6 +146,33 @@
146 146 </div>
147 147 </div>-->
148 148  
  149 + <!--foreach ($ad_employer->jobs_code as $it_um)
  150 + <pre> print_r($it_um) }}</pre>
  151 + endforeach-->
  152 + <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group">
  153 + <label class="form-group__label">Редактирование должностей</label>
  154 + <div class="form-group__item">
  155 + <div class="select">
  156 + <select class="js-select2" name="job_title_id[]" id="job_title_id[]" multiple="multiple">
  157 + @php $i = 1 @endphp
  158 + @if ($jobs->count())
  159 + @foreach($jobs as $it)
  160 + @php $selected = false; @endphp
  161 + @foreach ($ad_employer->jobs_code as $it_um)
  162 + @if (isset($it_um->job_title_id))
  163 + @if ($it_um->job_title_id == $it->id))
  164 + @php $selected = true; @endphp
  165 + @endif
  166 + @endif
  167 + @endforeach
  168 + <option value="{{ $it->id }}" @if ($selected) selected @endif>{{ $it->name }}</option>
  169 + @endforeach
  170 + @endif
  171 + </select>
  172 + </div>
  173 + </div>
  174 + </div>
  175 +
149 176 <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group">
150 177 <label class="form-group__label">Описание вакансии</label>
151 178 <div class="form-group__item">
... ... @@ -158,24 +185,24 @@
158 185 </div>
159 186 </div>
160 187  
161   - <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group">
  188 + <!--<div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group">
162 189 <h4 class="form-group__label">Редактирование должностей</h4>
163 190 <div class="form-group__item">
164   - <a href="{{ route('employer.add_job_in_vac', ['ad_employer' => $ad_employer->id]) }}" class="button">Добавить</a>
165   -
166   - @if ($ad_employer->jobs->count())
167   - @foreach ($ad_employer->jobs as $key => $it_um)
168   - <p>@if (isset($ad_employer->jobs_code[$key]))
169   - <a href="{{ route('employer.edit_job_in_vac', ['ad_job' => $ad_employer->jobs_code[$key]->id, 'ad_employer' => $ad_employer->id, 'job_title_id' => $it_um->id]) }}" style="text-decoration: underline">{{$it_um->name}}</a>
170   - <a href="{{ route('employer.delete_job_in_vac', ['ad_job' => $ad_employer->jobs_code[$key]->id]) }}" style="text-decoration: underline">(Del)</a>
171   - @endif
  191 + <a href=" route('employer.add_job_in_vac', ['ad_employer' => $ad_employer->id]) }}" class="button">Добавить</a>
  192 +
  193 + if ($ad_employer->jobs->count())
  194 + foreach ($ad_employer->jobs as $key => $it_um)
  195 + <p>if (isset($ad_employer->jobs_code[$key]))
  196 + <a href=" route('employer.edit_job_in_vac', ['ad_job' => $ad_employer->jobs_code[$key]->id, 'ad_employer' => $ad_employer->id, 'job_title_id' => $it_um->id]) }}" style="text-decoration: underline">$it_um->name}}</a>
  197 + <a href=" route('employer.delete_job_in_vac', ['ad_job' => $ad_employer->jobs_code[$key]->id]) }}" style="text-decoration: underline">(Del)</a>
  198 + endif
172 199 </p>
173   - @endforeach
174   - @else
  200 + endforeach
  201 + else
175 202 Нет связанных <br> с вакансией должностей
176   - @endif
  203 + endif
177 204 </div>
178   - </div>
  205 + </div>-->
179 206 </div>
180 207  
181 208 <a class="button cabinet__submit" href="{{ route('employer.vacancy_list') }}">Назад</a>
resources/views/info_company_new.blade.php
... ... @@ -198,8 +198,7 @@
198 198  
199 199 <div class="main__employer-page-body-item" data-body="2">
200 200 <div class="main__employer-page-two">
201   - @foreach ($company[0]->ads as $job)
202   - @foreach ($job->ad_job as $item)
  201 + @foreach ($ads as $job)
203 202 <div class="main__employer-page-two-item">
204 203 <div class="main__employer-page-two-item-toper">
205 204 @if (!empty($company[0]->logo))
... ... @@ -208,30 +207,37 @@
208 207 <img src="{{ asset('images/default_ship.jpg') }}" alt="{{ $job->name }}">
209 208 @endif
210 209 <span>{{ $job->name }}</span>
  210 + <!--<span>Описание:
  211 + $job->text !!}
  212 + </span>-->
211 213 </div>
212   - <div class="main__employer-page-two-item-title">{{ $item->flot }}</div>
  214 + <!--<div class="main__employer-page-two-item-title"> $item->flot }}</div>-->
213 215 <div class="main__employer-page-two-item-text">
214   - <div class="main__employer-page-two-item-text-name">
215   - {{ $item->job_title->name }}
216   - </div>
217   - <div class="main__employer-page-two-item-text-body">
218   - <p>Зарплата:{{ $item->min_salary }} - {{ $item->max_salary }}р + {{ $item->sytki }} суточные.</p>
219   - <p>Контракт: {{ $item->period }} мес.</p>
220   - </div>
  216 + @if ((isset($job->jobs)) && ($job->jobs->count()))
  217 + @foreach($job->jobs as $item)
  218 + <a class="main__employer-page-two-item-text-name">
  219 + {{ $item->name }}
  220 + </a>
  221 + @endforeach
  222 + @endif
  223 + <!--<div class="main__employer-page-two-item-text-body">
  224 + <p>Зарплата: $item->min_salary }} - $item->max_salary }}р + $item->sytki }} суточные.</p>
  225 + <p>Контракт: $item->period }} мес.</p>
  226 + </div>-->
221 227 </div>
222   - <div class="main__employer-page-two-item-text">
  228 + <!--<div class="main__employer-page-two-item-text">
223 229 <div class="main__employer-page-two-item-text-name">Район работы</div>
224 230 <div class="main__employer-page-two-item-text-body">
225   - <p>{{ $item->region }}</p>
  231 + <p> $item->region }}</p>
226 232 </div>
227 233 </div>
228 234 <div class="main__employer-page-two-item-text">
229 235 <div class="main__employer-page-two-item-text-name">Посадка</div>
230 236 <div class="main__employer-page-two-item-text-body">
231   - <p> {{ $item->start }}</p>
232   - {!! $item->description !!}
  237 + <p> $item->start }}</p>
  238 + !! $item->description !!}
233 239 </div>
234   - </div>
  240 + </div>-->
235 241 <div class="main__employer-page-two-item-text">
236 242 <div class="main__employer-page-two-item-text-name">Звонить по вопросам на:
237 243 </div>
... ... @@ -247,12 +253,16 @@
247 253 <a href="mailto: {{ $job->email }}">{{ $job->email }}</a>
248 254 </div>
249 255 </div>
  256 + @if ((isset($job->jobs)) && ($job->jobs->count()))
250 257 <div class="main__employer-page-two-item-tags">
251   - <span class="main__employer-page-two-item-tag">#{{ $item->job_title->name }}</span>
  258 + @foreach ($job->jobs as $item)
  259 + <span class="main__employer-page-two-item-tag">#{{ $item->name }}</span>
  260 + @endforeach
252 261 </div>
  262 + @endif
253 263 <div class="main__employer-page-two-item-buttons">
254 264  
255   - <button type="button" data-fancybox data-src="#send" data-vacancy="{{ $item->job_title->id }}" data-uid="{{ $user_id }}" data-tuid="{{ $company[0]->users->id }}" data-options='{"touch":false,"autoFocus":false}'
  265 + <button type="button" data-fancybox data-src="#send" data-vacancy="{{ $job->id }}" data-uid="{{ $user_id }}" data-tuid="{{ $company[0]->users->id }}" data-options='{"touch":false,"autoFocus":false}'
256 266 class="button main__employer-page-two-item-button js_send_it_button">Оставить
257 267 отклик...</button>
258 268  
... ... @@ -269,8 +279,11 @@
269 279 </button>
270 280 </div>
271 281 </div>
272   - @endforeach
273 282 @endforeach
  283 +
  284 + <div style="margin-top: 20px">
  285 + {{ $ads->onEachSide(0)->appends($_GET)->links('paginate') }}
  286 + </div>
274 287 <!--<button type="button" class="button button_light button_more main__employer-page-two-more js-toggle js-parent-toggle">
275 288 <span>Показать ещё</span>
276 289 <span>Скрыть</span>
... ... @@ -198,6 +198,7 @@ Route::group([
198 198  
199 199 // кабинет - пользователи
200 200 Route::get('users', [UsersController::class, 'index'])->name('users');
  201 + Route::get('user-delete/{user}', [UsersController::class, 'user_delete'])->name('user_delete');
201 202  
202 203 // кабинет - пользователи
203 204 Route::get('admin-users', [AdminController::class, 'index_admin'])->name('admin-users');