diff --git a/app/Http/Controllers/Admin/CategoryEmpController.php b/app/Http/Controllers/Admin/CategoryEmpController.php new file mode 100644 index 0000000..64d0cd2 --- /dev/null +++ b/app/Http/Controllers/Admin/CategoryEmpController.php @@ -0,0 +1,94 @@ +active()->paginate(15); + return view('admin.category-emp.index', compact('category')); + } + + /** + * Show the form for creating a new resource. + * + * @return \Illuminate\Http\Response + */ + public function create() + { + return view('admin.category-emp.add'); + } + + /** + * Store a newly created resource in storage. + * + * @param \Illuminate\Http\Request $request + * @return \Illuminate\Http\Response + */ + public function store(Request $request) + { + CategoryEmp::create($request->all()); + return redirect()->route('admin.category-emp.index'); + } + + /** + * Display the specified resource. + * + * @param \App\Models\CategoryEmp $categoryEmp + * @return \Illuminate\Http\Response + */ + public function show(CategoryEmp $category_emp) + { + // + } + + /** + * Show the form for editing the specified resource. + * + * @param \App\Models\CategoryEmp $categoryEmp + * @return \Illuminate\Http\Response + */ + public function edit(CategoryEmp $category_emp) + { + return view('admin.category-emp.edit', compact('category_emp')); + } + + /** + * Update the specified resource in storage. + * + * @param \Illuminate\Http\Request $request + * @param \App\Models\CategoryEmp $categoryEmp + * @return \Illuminate\Http\Response + */ + public function update(Request $request, CategoryEmp $category_emp) + { + $category_emp->update($request->all()); + return redirect()->route('admin.category-emp.index'); + } + + /** + * Remove the specified resource from storage. + * + * @param \App\Models\CategoryEmp $categoryEmp + * @return \Illuminate\Http\Response + */ + public function destroy(CategoryEmp $category_emp) + { + /*if (Auth::user()->id == 1) { + $category->delete(); + } else {*/ + $category_emp->update(['is_remove' => 1]); + //} + return redirect()->route('admin.category-emp.index'); + } +} diff --git a/app/Http/Controllers/Admin/EmployersController.php b/app/Http/Controllers/Admin/EmployersController.php index dfbe303..2dbf3e8 100644 --- a/app/Http/Controllers/Admin/EmployersController.php +++ b/app/Http/Controllers/Admin/EmployersController.php @@ -16,6 +16,8 @@ use Illuminate\Support\Facades\Validator; class EmployersController extends Controller { public function index(Request $request) { + //$all_employer = User::where('is_worker', '0')->count(); + if ($request->ajax()) { $user = User::find($request->id); $request->offsetUnset('id'); @@ -35,6 +37,7 @@ class EmployersController extends Controller $users = User::select(['users.*','users.id as usr_id', 'emp.id as emp_id', 'emp.*'])->join('employers as emp','emp.user_id','users.id') ->where('users.is_worker', '0'); + $all_employer = $users->count(); $find_key = ""; if (isset($request->find)) { $find_key = $request->find; @@ -52,7 +55,7 @@ class EmployersController extends Controller if ($request->ajax()) { return view('admin.employer.index_ajax', compact('users')); } else { - return view('admin.employer.index', compact('users', 'find_key')); + return view('admin.employer.index', compact('users', 'find_key', 'all_employer')); } } diff --git a/app/Models/CategoryEmp.php b/app/Models/CategoryEmp.php new file mode 100644 index 0000000..ef3d250 --- /dev/null +++ b/app/Models/CategoryEmp.php @@ -0,0 +1,20 @@ +where('is_remove', '=', '0'); + } +} diff --git a/database/migrations/2023_10_02_130611_alter_table_employers.php b/database/migrations/2023_10_02_130611_alter_table_employers.php new file mode 100644 index 0000000..a65e5f6 --- /dev/null +++ b/database/migrations/2023_10_02_130611_alter_table_employers.php @@ -0,0 +1,34 @@ +text('comment_admin')->nullable(); + $table->string('category', 255)->default('Не определен'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('employers', function (Blueprint $table) { + $table->dropColumn('comment_admin'); + $table->dropColumn('category'); + }); + } +}; diff --git a/database/migrations/2023_10_02_130747_create_category_emps_table.php b/database/migrations/2023_10_02_130747_create_category_emps_table.php new file mode 100644 index 0000000..b1adea5 --- /dev/null +++ b/database/migrations/2023_10_02_130747_create_category_emps_table.php @@ -0,0 +1,33 @@ +id(); + $table->string('name', 255)->nullable(false); + $table->boolean('is_remove')->default(false); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('category_emps'); + } +}; diff --git a/database/migrations/2023_10_02_132059_alter_table_ad_employers.php b/database/migrations/2023_10_02_132059_alter_table_ad_employers.php new file mode 100644 index 0000000..3be0f51 --- /dev/null +++ b/database/migrations/2023_10_02_132059_alter_table_ad_employers.php @@ -0,0 +1,36 @@ +boolean('sroch_vacancy')->default(0); + $table->boolean('favorite_vacancy')->default(0); + $table->string('status', 255)->default('Не задан'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('ad_employers', function (Blueprint $table) { + $table->dropColumn('sroch_vacancy'); + $table->dropColumn('favorite_vacancy'); + $table->dropColumn('status'); + }); + } +}; diff --git a/resources/views/admin/category-emp/add.blade.php b/resources/views/admin/category-emp/add.blade.php new file mode 100644 index 0000000..276253d --- /dev/null +++ b/resources/views/admin/category-emp/add.blade.php @@ -0,0 +1,7 @@ +@extends('layout.admin', ['title' => 'Админка - Добавление категории работодателей']) + +@section('content') +
+ @include('admin.category-emp.form') +
+@endsection diff --git a/resources/views/admin/category-emp/edit.blade.php b/resources/views/admin/category-emp/edit.blade.php new file mode 100644 index 0000000..8a19bcf --- /dev/null +++ b/resources/views/admin/category-emp/edit.blade.php @@ -0,0 +1,7 @@ +@extends('layout.admin', ['title' => 'Админка - Редактирование категории работодателей']) + +@section('content') +
+ @include('admin.category-emp.form') +
+@endsection diff --git a/resources/views/admin/category-emp/form.blade.php b/resources/views/admin/category-emp/form.blade.php new file mode 100644 index 0000000..1306027 --- /dev/null +++ b/resources/views/admin/category-emp/form.blade.php @@ -0,0 +1,32 @@ +@csrf + +@isset($category_emp) + @method('PUT') +@endisset + +
+
+ +
+
+ + Назад +
+
+
diff --git a/resources/views/admin/category-emp/index.blade.php b/resources/views/admin/category-emp/index.blade.php new file mode 100644 index 0000000..5709f60 --- /dev/null +++ b/resources/views/admin/category-emp/index.blade.php @@ -0,0 +1,61 @@ +@extends('layout.admin', ['title' => 'Админка - Категории работодателей']) + +@section('script') + +@endsection + +@section('search') + +@endsection + +@section('content') + + + Добавить категорию + +
+
+ +
+ + + + + + + + + + + @foreach($category as $cat) + + + + + + + @endforeach + +
Название категорииДата созданияРедактировать
+ {{$cat->id}} + + {{$cat->name}} + + {{$cat->created_at}} + +
+ Изменить | + @csrf + @method('DELETE') + +
+
+
+ +
+ appends($_GET)->links('admin.pagginate'); ?> +
+
+@endsection diff --git a/resources/views/admin/employer/edit.blade.php b/resources/views/admin/employer/edit.blade.php index c512bd0..5541976 100644 --- a/resources/views/admin/employer/edit.blade.php +++ b/resources/views/admin/employer/edit.blade.php @@ -31,7 +31,7 @@