Commit 4452df3267fc3f634fda57bfe21b1c6b6bdececd

Authored by Андрей Ларионов
1 parent 9143ea2856

Миграции Категорий работодателей, работодателей и вакансий. Блейды, контроллеры …

…и модели категории работодателей

Showing 15 changed files with 390 additions and 6 deletions Side-by-side Diff

app/Http/Controllers/Admin/CategoryEmpController.php
... ... @@ -0,0 +1,94 @@
  1 +<?php
  2 +
  3 +namespace App\Http\Controllers\Admin;
  4 +
  5 +use App\Http\Controllers\Controller;
  6 +use App\Models\CategoryEmp;
  7 +use Illuminate\Http\Request;
  8 +
  9 +class CategoryEmpController extends Controller
  10 +{
  11 + /**
  12 + * Display a listing of the resource.
  13 + *
  14 + * @return \Illuminate\Http\Response
  15 + */
  16 + public function index()
  17 + {
  18 + $category = CategoryEmp::query()->active()->paginate(15);
  19 + return view('admin.category-emp.index', compact('category'));
  20 + }
  21 +
  22 + /**
  23 + * Show the form for creating a new resource.
  24 + *
  25 + * @return \Illuminate\Http\Response
  26 + */
  27 + public function create()
  28 + {
  29 + return view('admin.category-emp.add');
  30 + }
  31 +
  32 + /**
  33 + * Store a newly created resource in storage.
  34 + *
  35 + * @param \Illuminate\Http\Request $request
  36 + * @return \Illuminate\Http\Response
  37 + */
  38 + public function store(Request $request)
  39 + {
  40 + CategoryEmp::create($request->all());
  41 + return redirect()->route('admin.category-emp.index');
  42 + }
  43 +
  44 + /**
  45 + * Display the specified resource.
  46 + *
  47 + * @param \App\Models\CategoryEmp $categoryEmp
  48 + * @return \Illuminate\Http\Response
  49 + */
  50 + public function show(CategoryEmp $category_emp)
  51 + {
  52 + //
  53 + }
  54 +
  55 + /**
  56 + * Show the form for editing the specified resource.
  57 + *
  58 + * @param \App\Models\CategoryEmp $categoryEmp
  59 + * @return \Illuminate\Http\Response
  60 + */
  61 + public function edit(CategoryEmp $category_emp)
  62 + {
  63 + return view('admin.category-emp.edit', compact('category_emp'));
  64 + }
  65 +
  66 + /**
  67 + * Update the specified resource in storage.
  68 + *
  69 + * @param \Illuminate\Http\Request $request
  70 + * @param \App\Models\CategoryEmp $categoryEmp
  71 + * @return \Illuminate\Http\Response
  72 + */
  73 + public function update(Request $request, CategoryEmp $category_emp)
  74 + {
  75 + $category_emp->update($request->all());
  76 + return redirect()->route('admin.category-emp.index');
  77 + }
  78 +
  79 + /**
  80 + * Remove the specified resource from storage.
  81 + *
  82 + * @param \App\Models\CategoryEmp $categoryEmp
  83 + * @return \Illuminate\Http\Response
  84 + */
  85 + public function destroy(CategoryEmp $category_emp)
  86 + {
  87 + /*if (Auth::user()->id == 1) {
  88 + $category->delete();
  89 + } else {*/
  90 + $category_emp->update(['is_remove' => 1]);
  91 + //}
  92 + return redirect()->route('admin.category-emp.index');
  93 + }
  94 +}
app/Http/Controllers/Admin/EmployersController.php
... ... @@ -16,6 +16,8 @@ use Illuminate\Support\Facades\Validator;
16 16 class EmployersController extends Controller
17 17 {
18 18 public function index(Request $request) {
  19 + //$all_employer = User::where('is_worker', '0')->count();
  20 +
19 21 if ($request->ajax()) {
20 22 $user = User::find($request->id);
21 23 $request->offsetUnset('id');
... ... @@ -35,6 +37,7 @@ class EmployersController extends Controller
35 37  
36 38 $users = User::select(['users.*','users.id as usr_id', 'emp.id as emp_id', 'emp.*'])->join('employers as emp','emp.user_id','users.id')
37 39 ->where('users.is_worker', '0');
  40 + $all_employer = $users->count();
38 41 $find_key = "";
39 42 if (isset($request->find)) {
40 43 $find_key = $request->find;
... ... @@ -52,7 +55,7 @@ class EmployersController extends Controller
52 55 if ($request->ajax()) {
53 56 return view('admin.employer.index_ajax', compact('users'));
54 57 } else {
55   - return view('admin.employer.index', compact('users', 'find_key'));
  58 + return view('admin.employer.index', compact('users', 'find_key', 'all_employer'));
56 59 }
57 60 }
58 61  
app/Models/CategoryEmp.php
... ... @@ -0,0 +1,20 @@
  1 +<?php
  2 +
  3 +namespace App\Models;
  4 +
  5 +use Illuminate\Database\Eloquent\Factories\HasFactory;
  6 +use Illuminate\Database\Eloquent\Model;
  7 +
  8 +class CategoryEmp extends Model
  9 +{
  10 + use HasFactory;
  11 +
  12 + protected $fillable = [
  13 + 'name',
  14 + 'is_remove'
  15 + ];
  16 +
  17 + public function scopeActive($query) {
  18 + return $query->where('is_remove', '=', '0');
  19 + }
  20 +}
database/migrations/2023_10_02_130611_alter_table_employers.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('employers', function (Blueprint $table) {
  17 + $table->text('comment_admin')->nullable();
  18 + $table->string('category', 255)->default('Не определен');
  19 + });
  20 + }
  21 +
  22 + /**
  23 + * Reverse the migrations.
  24 + *
  25 + * @return void
  26 + */
  27 + public function down()
  28 + {
  29 + Schema::table('employers', function (Blueprint $table) {
  30 + $table->dropColumn('comment_admin');
  31 + $table->dropColumn('category');
  32 + });
  33 + }
  34 +};
database/migrations/2023_10_02_130747_create_category_emps_table.php
... ... @@ -0,0 +1,33 @@
  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::create('category_emps', function (Blueprint $table) {
  17 + $table->id();
  18 + $table->string('name', 255)->nullable(false);
  19 + $table->boolean('is_remove')->default(false);
  20 + $table->timestamps();
  21 + });
  22 + }
  23 +
  24 + /**
  25 + * Reverse the migrations.
  26 + *
  27 + * @return void
  28 + */
  29 + public function down()
  30 + {
  31 + Schema::dropIfExists('category_emps');
  32 + }
  33 +};
database/migrations/2023_10_02_132059_alter_table_ad_employers.php
... ... @@ -0,0 +1,36 @@
  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('ad_employers', function (Blueprint $table) {
  17 + $table->boolean('sroch_vacancy')->default(0);
  18 + $table->boolean('favorite_vacancy')->default(0);
  19 + $table->string('status', 255)->default('Не задан');
  20 + });
  21 + }
  22 +
  23 + /**
  24 + * Reverse the migrations.
  25 + *
  26 + * @return void
  27 + */
  28 + public function down()
  29 + {
  30 + Schema::table('ad_employers', function (Blueprint $table) {
  31 + $table->dropColumn('sroch_vacancy');
  32 + $table->dropColumn('favorite_vacancy');
  33 + $table->dropColumn('status');
  34 + });
  35 + }
  36 +};
resources/views/admin/category-emp/add.blade.php
... ... @@ -0,0 +1,7 @@
  1 +@extends('layout.admin', ['title' => 'Админка - Добавление категории работодателей'])
  2 +
  3 +@section('content')
  4 + <form method="POST" action="{{ route('admin.category-emp.store') }}">
  5 + @include('admin.category-emp.form')
  6 + </form>
  7 +@endsection
resources/views/admin/category-emp/edit.blade.php
... ... @@ -0,0 +1,7 @@
  1 +@extends('layout.admin', ['title' => 'Админка - Редактирование категории работодателей'])
  2 +
  3 +@section('content')
  4 + <form method="POST" action="{{ route('admin.category-emp.update', ['category_emp' => $category_emp->id]) }}">
  5 + @include('admin.category-emp.form')
  6 + </form>
  7 +@endsection
resources/views/admin/category-emp/form.blade.php
... ... @@ -0,0 +1,32 @@
  1 +@csrf
  2 +
  3 +@isset($category_emp)
  4 + @method('PUT')
  5 +@endisset
  6 +
  7 +<div class="px-4 py-3 mb-8 bg-white rounded-lg shadow-md dark:bg-gray-800">
  8 + <label class="block text-sm">
  9 + <span class="text-gray-700 dark:text-gray-400">Имя категории</span>
  10 + <input name="name" id="name"
  11 + 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"
  12 + placeholder="Имя категории" value="{{ old('name') ?? $category_emp->name ?? '' }}"
  13 + />
  14 + @error('name')
  15 + <span class="text-xs text-red-600 dark:text-red-400">
  16 + {{ $message }}
  17 + </span>
  18 + @enderror
  19 + </label><br>
  20 +
  21 + <div class="flex flex-col flex-wrap mb-4 space-y-4 md:flex-row md:items-end md:space-x-4">
  22 + <div>
  23 + <button type="submit" class="px-3 py-1 text-sm font-medium leading-5 text-white transition-colors duration-150 bg-purple-600 border border-transparent rounded-md active:bg-purple-600 hover:bg-purple-700 focus:outline-none focus:shadow-outline-purple">
  24 + Сохранить
  25 + </button>
  26 + <a href="{{ route('admin.category-emp.index') }}"
  27 + class="px-3 py-1 text-sm font-medium leading-5 text-white transition-colors duration-150 bg-purple-600 border border-transparent rounded-md active:bg-purple-600 hover:bg-purple-700 focus:outline-none focus:shadow-outline-purple"
  28 + style="display: -webkit-inline-box; height: 30px!important;"
  29 + >Назад</a>
  30 + </div>
  31 + </div>
  32 +</div>
resources/views/admin/category-emp/index.blade.php
... ... @@ -0,0 +1,61 @@
  1 +@extends('layout.admin', ['title' => 'Админка - Категории работодателей'])
  2 +
  3 +@section('script')
  4 +
  5 +@endsection
  6 +
  7 +@section('search')
  8 +
  9 +@endsection
  10 +
  11 +@section('content')
  12 +
  13 + <a href="{{ route('admin.category-emp.create') }}" style="width: 175px" class="px-3 py-1 text-sm font-medium leading-5 text-white transition-colors duration-150 bg-purple-600 border border-transparent rounded-md active:bg-purple-600 hover:bg-purple-700 focus:outline-none focus:shadow-outline-purple">
  14 + Добавить категорию
  15 + </a>
  16 + <br>
  17 + <div class="w-full overflow-hidden rounded-lg shadow-xs" id="ajax_block">
  18 +
  19 + <div class="w-full overflow-x-auto">
  20 + <table class="w-full whitespace-no-wrap">
  21 + <thead>
  22 + <tr
  23 + class="text-xs font-semibold tracking-wide text-left text-gray-500 uppercase border-b dark:border-gray-700 bg-gray-50 dark:text-gray-400 dark:bg-gray-800"
  24 + >
  25 + <th class="px-4 py-3">№</th>
  26 + <th class="px-4 py-3">Название категории</th>
  27 + <th class="px-4 py-3">Дата создания</th>
  28 + <th class="px-4 py-3">Редактировать</th>
  29 + </tr>
  30 + </thead>
  31 + <tbody class="bg-white divide-y dark:divide-gray-700 dark:bg-gray-800">
  32 + @foreach($category as $cat)
  33 + <tr class="text-gray-700 dark:text-gray-400">
  34 + <td class="px-4 py-3">
  35 + {{$cat->id}}
  36 + </td>
  37 + <td class="px-4 py-3">
  38 + {{$cat->name}}
  39 + </td>
  40 + <td class="px-4 py-3">
  41 + {{$cat->created_at}}
  42 + </td>
  43 + <td class="px-4 py-3 text-sm_">
  44 + <form action="{{ route('admin.category-emp.destroy', ['category_emp' => $cat->id]) }}" method="POST">
  45 + <a href="{{ route('admin.category-emp.edit', ['category_emp' => $cat->id]) }}">Изменить</a> |
  46 + @csrf
  47 + @method('DELETE')
  48 + <input class="btn btn-danger" type="submit" value="Удалить"/>
  49 + </form>
  50 + </td>
  51 + </tr>
  52 + @endforeach
  53 + </tbody>
  54 + </table>
  55 + </div>
  56 +
  57 + <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">
  58 + <?=$category->appends($_GET)->links('admin.pagginate'); ?>
  59 + </div>
  60 + </div>
  61 +@endsection
resources/views/admin/employer/edit.blade.php
... ... @@ -31,7 +31,7 @@
31 31  
32 32 <label class="block text-sm">
33 33 <span class="text-gray-700 dark:text-gray-400">Email</span>
34   - <input name="email" id="email"
  34 + <input name="email" id="email" disabled
35 35 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"
36 36 placeholder="Почта" value="{{ old('email') ?? $employer->email ?? '' }}"
37 37 />
resources/views/admin/employer/index.blade.php
... ... @@ -43,6 +43,27 @@
43 43 @endsection
44 44  
45 45 @section('content')
  46 + <div class="grid gap-6 mb-8 md:grid-cols-2 xl:grid-cols-4">
  47 +
  48 + <div class="flex items-center p-4 bg-white rounded-lg shadow-xs dark:bg-gray-800">
  49 + <div class="p-3 mr-4 text-orange-500 bg-orange-100 rounded-full dark:text-orange-100 dark:bg-orange-500">
  50 + <svg class="w-5 h-5" fill="currentColor" viewBox="0 0 20 20">
  51 + <path
  52 + d="M13 6a3 3 0 11-6 0 3 3 0 016 0zM18 8a2 2 0 11-4 0 2 2 0 014 0zM14 15a4 4 0 00-8 0v3h8v-3zM6 8a2 2 0 11-4 0 2 2 0 014 0zM16 18v-3a5.972 5.972 0 00-.75-2.906A3.005 3.005 0 0119 15v3h-3zM4.75 12.094A5.973 5.973 0 004 15v3H1v-3a3 3 0 013.75-2.906z"></path>
  53 + </svg>
  54 + </div>
  55 + <div>
  56 + <p class="mb-2 text-sm font-medium text-gray-600 dark:text-gray-400">
  57 + Всего работодателей
  58 + </p>
  59 + <p class="text-lg font-semibold text-gray-700 dark:text-gray-200">
  60 + {{ $all_employer }}
  61 + </p>
  62 + </div>
  63 + </div>
  64 + </div>
  65 +
  66 +
46 67 <div class="w-full overflow-hidden rounded-lg shadow-xs" id="ajax_block">
47 68 <div class="w-full overflow-x-auto">
48 69 <table class="w-full whitespace-no-wrap">
resources/views/admin/index.blade.php
... ... @@ -214,9 +214,9 @@
214 214 <div class="absolute inset-0 rounded-full shadow-inner" aria-hidden="true"></div>
215 215 </div>
216 216 <div>
217   - <p class="font-semibold"><a href="{{ route('admin.categories.index') }}">Категории</a></p>
  217 + <p class="font-semibold"><a href="{{ route('admin.categories.index') }}">Категории вакансий</a></p>
218 218 <p class="text-xs text-gray-600 dark:text-gray-400">
219   - Справочник категории (по умолчанию: река, море, река-море)
  219 + Справочник категории вакансий (по умолчанию: река, море, река-море)
220 220 </p>
221 221 </div>
222 222 </div>
... ... @@ -241,6 +241,33 @@
241 241 <div class="absolute inset-0 rounded-full shadow-inner" aria-hidden="true"></div>
242 242 </div>
243 243 <div>
  244 + <p class="font-semibold"><a href="{{ route('admin.category-emp.index') }}">Категории работодателей</a></p>
  245 + <p class="text-xs text-gray-600 dark:text-gray-400">
  246 + Справочник категории работодателей <br>(по умолчанию: не определен, оплатили, согласование, не оплачен)
  247 + </p>
  248 + </div>
  249 + </div>
  250 + </td>
  251 + <td class="px-4 py-3 text-sm">
  252 + category_emps
  253 + </td>
  254 + <td class="px-4 py-3 text-xs">
  255 + <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">
  256 + Доступно
  257 + </span>
  258 + </td>
  259 + <td class="px-4 py-3 text-sm">
  260 + октябрь 2023
  261 + </td>
  262 + </tr>
  263 +
  264 + <tr class="text-gray-700 dark:text-gray-400">
  265 + <td class="px-4 py-3">
  266 + <div class="flex items-center text-sm">
  267 + <div class="relative hidden w-8 h-8 mr-3 rounded-full md:block">
  268 + <div class="absolute inset-0 rounded-full shadow-inner" aria-hidden="true"></div>
  269 + </div>
  270 + <div>
244 271 <p class="font-semibold"><a href="{{ route('admin.job-titles.index') }}">Должности</a></p>
245 272 <p class="text-xs text-gray-600 dark:text-gray-400">
246 273 Справочник должности (все должности проекта)
resources/views/layout/admin.blade.php
... ... @@ -306,7 +306,10 @@
306 306 <a class="w-full" href="{{ route('admin.job-titles.index') }}">Должности</a>
307 307 </li>
308 308 <li class="px-2 py-1 transition-colors duration-150 hover:text-gray-800 dark:hover:text-gray-200">
309   - <a class="w-full" href="{{ route('admin.categories.index') }}">Категории</a>
  309 + <a class="w-full" href="{{ route('admin.categories.index') }}">Категории вакансий</a>
  310 + </li>
  311 + <li class="px-2 py-1 transition-colors duration-150 hover:text-gray-800 dark:hover:text-gray-200">
  312 + <a class="w-full" href="{{ route('admin.category-emp.index') }}">Категории работодателей</a>
310 313 </li>
311 314 <li class="px-2 py-1 transition-colors duration-150 hover:text-gray-800 dark:hover:text-gray-200">
312 315 <a class="w-full" href="{{ route('admin.infobloks.index') }}">Блоки-Дипломы</a>
... ... @@ -699,7 +702,10 @@
699 702 <a class="w-full" href="{{ route('admin.job-titles.index') }}">Должности</a>
700 703 </li>
701 704 <li class="px-2 py-1 transition-colors duration-150 hover:text-gray-800 dark:hover:text-gray-200">
702   - <a class="w-full" href="{{ route('admin.categories.index') }}">Категории</a>
  705 + <a class="w-full" href="{{ route('admin.categories.index') }}">Категории вакансий</a>
  706 + </li>
  707 + <li class="px-2 py-1 transition-colors duration-150 hover:text-gray-800 dark:hover:text-gray-200">
  708 + <a class="w-full" href="{{ route('admin.category-emp.index') }}">Категории работодателей</a>
703 709 </li>
704 710 <li class="px-2 py-1 transition-colors duration-150 hover:text-gray-800 dark:hover:text-gray-200">
705 711 <a class="w-full" href="{{ route('admin.infobloks.index') }}">Блоки-Дипломы</a>
... ... @@ -2,6 +2,7 @@
2 2  
3 3 use App\Http\Controllers\Admin\AdminController;
4 4 use App\Http\Controllers\Admin\CategoryController;
  5 +use App\Http\Controllers\Admin\CategoryEmpController;
5 6 use App\Http\Controllers\Admin\EmployersController;
6 7 use App\Http\Controllers\Admin\InfoBloksController;
7 8 use App\Http\Controllers\Admin\JobTitlesController;
... ... @@ -192,6 +193,8 @@ Route::group([
192 193 */
193 194 Route::resource('categories', CategoryController::class, ['except' => ['show']]);
194 195  
  196 + // CRUD-операции над справочником Категории для работодателей
  197 + Route::resource('category-emp', CategoryEmpController::class, ['except' => ['show']]);
195 198  
196 199 //Route::get('job-titles', [AdminController::class, 'index'])->name('job-titles');
197 200 /*