diff --git a/app/Http/Controllers/Admin/Ad_EmployersController.php b/app/Http/Controllers/Admin/Ad_EmployersController.php index 1c77cb7..efefbbb 100644 --- a/app/Http/Controllers/Admin/Ad_EmployersController.php +++ b/app/Http/Controllers/Admin/Ad_EmployersController.php @@ -18,7 +18,7 @@ class Ad_EmployersController extends Controller public function index(Request $request) { $title = 'Админка - Вакансии работодателей'; - $ad_employers = Ad_employer::where('is_remove', '0')->paginate(15); + $ad_employers = Ad_employer::with('employer')->with('jobs')->where('is_remove', '0')->paginate(15); return view('admin.ad_employers.index', compact('ad_employers', 'title')); diff --git a/app/Http/Controllers/Admin/CategoryEmpController.php b/app/Http/Controllers/Admin/CategoryEmpController.php index 64d0cd2..5af9bc8 100644 --- a/app/Http/Controllers/Admin/CategoryEmpController.php +++ b/app/Http/Controllers/Admin/CategoryEmpController.php @@ -3,6 +3,7 @@ namespace App\Http\Controllers\Admin; use App\Http\Controllers\Controller; +use App\Http\Requests\CategoryEmpRequest; use App\Models\CategoryEmp; use Illuminate\Http\Request; @@ -35,7 +36,7 @@ class CategoryEmpController extends Controller * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ - public function store(Request $request) + public function store(CategoryEmpRequest $request) { CategoryEmp::create($request->all()); return redirect()->route('admin.category-emp.index'); @@ -70,7 +71,7 @@ class CategoryEmpController extends Controller * @param \App\Models\CategoryEmp $categoryEmp * @return \Illuminate\Http\Response */ - public function update(Request $request, CategoryEmp $category_emp) + public function update(CategoryEmpRequest $request, CategoryEmp $category_emp) { $category_emp->update($request->all()); return redirect()->route('admin.category-emp.index'); diff --git a/app/Http/Controllers/Admin/EducationController.php b/app/Http/Controllers/Admin/EducationController.php new file mode 100644 index 0000000..0840422 --- /dev/null +++ b/app/Http/Controllers/Admin/EducationController.php @@ -0,0 +1,91 @@ +active()->paginate(15); + return view('admin.education.index', compact('education')); + } + + /** + * Show the form for creating a new resource. + * + * @return \Illuminate\Http\Response + */ + public function create() + { + return view('admin.education.add'); + } + + /** + * Store a newly created resource in storage. + * + * @param \Illuminate\Http\Request $request + * @return \Illuminate\Http\Response + */ + public function store(EducationRequest $request) + { + Education::create($request->all()); + return redirect()->route('admin.education.index'); + } + + /** + * Display the specified resource. + * + * @param \App\Models\Education $education + * @return \Illuminate\Http\Response + */ + public function show(Education $education) + { + // + } + + /** + * Show the form for editing the specified resource. + * + * @param \App\Models\Education $education + * @return \Illuminate\Http\Response + */ + public function edit(Education $education) + { + return view('admin.education.edit', compact('education')); + } + + /** + * Update the specified resource in storage. + * + * @param \Illuminate\Http\Request $request + * @param \App\Models\Education $education + * @return \Illuminate\Http\Response + */ + public function update(EducationRequest $request, Education $education) + { + $education->update($request->all()); + return redirect()->route('admin.education.index'); + } + + /** + * Remove the specified resource from storage. + * + * @param \App\Models\Education $education + * @return \Illuminate\Http\Response + */ + public function destroy(Education $education) + { + $education->update(['is_remove' => 1]); + return redirect()->route('admin.education.index'); + } +} diff --git a/app/Http/Controllers/Admin/EmployersController.php b/app/Http/Controllers/Admin/EmployersController.php index 2dbf3e8..0574469 100644 --- a/app/Http/Controllers/Admin/EmployersController.php +++ b/app/Http/Controllers/Admin/EmployersController.php @@ -5,6 +5,7 @@ namespace App\Http\Controllers\Admin; use App\Http\Controllers\Controller; use App\Models\Ad_employer; use App\Models\Answer; +use App\Models\CategoryEmp; use App\Models\Employer; use App\Models\Static_ad; use App\Models\User; @@ -35,7 +36,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') + $users = User::with('employers')->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 = ""; @@ -60,7 +61,8 @@ class EmployersController extends Controller } public function form_update_employer(Employer $employer) { - return view('admin.employer.edit', compact('employer')); + $select_category = CategoryEmp::query()->active()->get(); + return view('admin.employer.edit', compact('employer', 'select_category')); } public function update_employer(Employer $employer, Request $request) @@ -75,6 +77,8 @@ class EmployersController extends Controller unset($params['oficial_status']); unset($params['social_is']); unset($params['sending_is']); + unset($params['category']); + unset($params['comment_admin']); $rules = [ 'name' => 'required|string|max:255', @@ -112,6 +116,8 @@ class EmployersController extends Controller $employer->oficial_status = $request->oficial_status; $employer->social_is = $request->social_is; $employer->sending_is = $request->sending_is; + $employer->category = $request->category; + $employer->comment_admin = $request->comment_admin; if ($request->has('logo')) { if (!empty($employer->logo)) { @@ -129,6 +135,23 @@ class EmployersController extends Controller } } + // Удаление работодателя, вакансий и профиля юзера + public function delete_employer(Employer $employer, User $user) { + try { + if (!empty($employer)) { + $employer->ads()->delete(); + if (!empty($employer->logo)) { + Storage::delete($employer->logo); + } + $employer->delete(); + } + } finally { + $user->delete(); + } + + return redirect()->route('admin.employers')->with('success', 'Данные были удалены о работодателе'); + } + // кабинет - отзывы о работодателе для модерации public function answers(Request $request) { if ($request->ajax()) { diff --git a/app/Http/Controllers/Admin/GroupsController.php b/app/Http/Controllers/Admin/GroupsController.php index b690ba3..f36aa5a 100644 --- a/app/Http/Controllers/Admin/GroupsController.php +++ b/app/Http/Controllers/Admin/GroupsController.php @@ -17,7 +17,7 @@ class GroupsController extends Controller // индексная страница public function index() { - $groups = Group_user::query()->active()->paginate(15); + $groups = Group_user::with('user')->with('ingroup')->active()->paginate(15); return view('admin.groups.index', compact('groups')); } diff --git a/app/Http/Controllers/Admin/MsgAnswersController.php b/app/Http/Controllers/Admin/MsgAnswersController.php index d2029b5..18350ad 100644 --- a/app/Http/Controllers/Admin/MsgAnswersController.php +++ b/app/Http/Controllers/Admin/MsgAnswersController.php @@ -13,7 +13,7 @@ use Illuminate\Support\Facades\Validator; class MsgAnswersController extends Controller { public function messages() { - $Msgs = Message::query()->orderByDesc('created_at')->paginate(25); + $Msgs = Message::with('user_from')->with('user_to')->with('response')->orderByDesc('created_at')->paginate(25); return view('admin.messages', compact('Msgs')); } @@ -28,7 +28,8 @@ class MsgAnswersController extends Controller $id_admin = Auth::user()->id; $users = User::query()->OrderBy('name')->get(); - $Msgs = Message::query()->where('user_id', '=', $id_admin) + $Msgs = Message::with('user_from')->with('user_to')->with('response') + ->where('user_id', '=', $id_admin) ->orWhere('to_user_id', '=', $id_admin) ->orderByDesc('created_at')->paginate(5); diff --git a/app/Http/Controllers/Admin/WorkersController.php b/app/Http/Controllers/Admin/WorkersController.php index f17e2e4..6a57bdd 100644 --- a/app/Http/Controllers/Admin/WorkersController.php +++ b/app/Http/Controllers/Admin/WorkersController.php @@ -21,7 +21,7 @@ class WorkersController extends Controller $user->update($request->all()); } - $users = User::where('is_worker', '1'); + $users = User::with('workers')->where('is_worker', '1'); $find_key = ""; if (isset($request->find)) { $find_key = $request->find; diff --git a/app/Http/Requests/CategoryEmpRequest.php b/app/Http/Requests/CategoryEmpRequest.php new file mode 100644 index 0000000..3053385 --- /dev/null +++ b/app/Http/Requests/CategoryEmpRequest.php @@ -0,0 +1,45 @@ + + */ + public function rules() + { + return [ + 'name' => 'required|min:3|max:255', + ]; + } + + public function messages() { + return [ + 'required' => 'Поле :attribute обязательно для ввода', + 'min' => [ + 'string' => 'Поле «:attribute» должно быть не меньше :min символов', + 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' + ], + 'max' => [ + 'string' => 'Поле «:attribute» должно быть не больше :max символов', + 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' + ], + + ]; + } +} diff --git a/app/Http/Requests/EducationRequest.php b/app/Http/Requests/EducationRequest.php new file mode 100644 index 0000000..64d3414 --- /dev/null +++ b/app/Http/Requests/EducationRequest.php @@ -0,0 +1,45 @@ + + */ + public function rules() + { + return [ + 'name' => 'required|min:3|max:255', + ]; + } + + public function messages() { + return [ + 'required' => 'Поле :attribute обязательно для ввода', + 'min' => [ + 'string' => 'Поле «:attribute» должно быть не меньше :min символов', + 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' + ], + 'max' => [ + 'string' => 'Поле «:attribute» должно быть не больше :max символов', + 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' + ], + + ]; + } +} diff --git a/app/Models/Education.php b/app/Models/Education.php new file mode 100644 index 0000000..cef0e50 --- /dev/null +++ b/app/Models/Education.php @@ -0,0 +1,20 @@ +where('is_remove', '=', '0'); + } +} diff --git a/app/Providers/MyServiceProvider.php b/app/Providers/MyServiceProvider.php index d7b8908..3eefb6d 100644 --- a/app/Providers/MyServiceProvider.php +++ b/app/Providers/MyServiceProvider.php @@ -48,7 +48,7 @@ class MyServiceProvider extends ServiceProvider } ); - $views2 = ['layout.admin']; + $views2 = ['layout.admin', 'admin.index']; View::composer($views2, function($view){ @@ -59,7 +59,7 @@ class MyServiceProvider extends ServiceProvider '), ['uid' => $id] ); - $view->with(['MsgCount' => $query[0]->MsgCount]); + $view->with(['MsgCount' => $query[0]->MsgCount, 'UserId' => $id]); } ); } diff --git a/database/migrations/2023_10_03_114608_create_education_table.php b/database/migrations/2023_10_03_114608_create_education_table.php new file mode 100644 index 0000000..8f0f09d --- /dev/null +++ b/database/migrations/2023_10_03_114608_create_education_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('education'); + } +}; diff --git a/database/migrations/2023_10_03_114801_alter_table_workers.php b/database/migrations/2023_10_03_114801_alter_table_workers.php new file mode 100644 index 0000000..ced27a0 --- /dev/null +++ b/database/migrations/2023_10_03_114801_alter_table_workers.php @@ -0,0 +1,32 @@ +string('education', 255)->default('Не указано'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('workers', function (Blueprint $table) { + $table->dropColumn('education'); + }); + } +}; diff --git a/resources/views/admin/education/add.blade.php b/resources/views/admin/education/add.blade.php new file mode 100644 index 0000000..815a736 --- /dev/null +++ b/resources/views/admin/education/add.blade.php @@ -0,0 +1,7 @@ +@extends('layout.admin', ['title' => 'Админка - Добавление образования']) + +@section('content') +
+@endsection diff --git a/resources/views/admin/education/edit.blade.php b/resources/views/admin/education/edit.blade.php new file mode 100644 index 0000000..cf7800b --- /dev/null +++ b/resources/views/admin/education/edit.blade.php @@ -0,0 +1,7 @@ +@extends('layout.admin', ['title' => 'Админка - Редактирование образования']) + +@section('content') + +@endsection diff --git a/resources/views/admin/education/form.blade.php b/resources/views/admin/education/form.blade.php new file mode 100644 index 0000000..d52f581 --- /dev/null +++ b/resources/views/admin/education/form.blade.php @@ -0,0 +1,32 @@ +@csrf + +@isset($education) + @method('PUT') +@endisset + +№ | +Название образования | +Дата создания | +Редактировать | +
---|---|---|---|
+ {{$cat->id}} + | ++ {{$cat->name}} + | ++ {{$cat->created_at}} + | ++ + | +
+ @if ($UserId == 1) + Пользователи + @else + Пользователи + @endif +
- Все пользователи сайта + Все пользователи сайта. Управление ими. Только для разработчика!