From 00652ea5794c5fcfdfd58d259a3aecdedf5983f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BD=D0=B4=D1=80=D0=B5=D0=B9=20=20=D0=9B=D0=B0=D1=80?= =?UTF-8?q?=D0=B8=D0=BE=D0=BD=D0=BE=D0=B2?= Date: Tue, 3 Oct 2023 21:22:26 +0700 Subject: [PATCH] =?UTF-8?q?=D0=9E=D0=BF=D1=82=D0=B8=D0=BC=D0=B8=D0=B7=D0=B0=D1?= =?UTF-8?q?=86=D0=B8=D1=8F=20=D0=B7=D0=B0=D0=BF=D1=80=D0=BE=D1=81=D0=BE=D0=B2?= =?UTF-8?q?=20=D0=91=D0=94,=20=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BE=D1=87=D0=BD?= =?UTF-8?q?=D0=B8=D0=BA=20=D0=BE=D0=B1=D1=80=D0=B0=D0=B7=D0=BE=D0=B2=D0=B0=D0?= =?UTF-8?q?=BD=D0=B8=D0=B5,=20=D0=BC=D0=BE=D0=B4=D0=B8=D1=84=D0=B8=D0=BA=D0=B0?= =?UTF-8?q?=D1=86=D0=B8=D1=8F=20=D0=B0=D0=B4=D0=BC=D0=B8=D0=BD=D0=BA=D0=B8=20?= =?UTF-8?q?=D0=BF=D0=BE=20=D0=BF=D1=80=D0=BE=D1=81=D1=8C=D0=B1=D0=B5=20=D0=B7?= =?UTF-8?q?=D0=B0=D0=BA=D0=B0=D0=B7=D1=87=D0=B8=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/Admin/Ad_EmployersController.php | 2 +- .../Controllers/Admin/CategoryEmpController.php | 5 +- app/Http/Controllers/Admin/EducationController.php | 91 ++++++++++ app/Http/Controllers/Admin/EmployersController.php | 27 ++- app/Http/Controllers/Admin/GroupsController.php | 2 +- .../Controllers/Admin/MsgAnswersController.php | 5 +- app/Http/Controllers/Admin/WorkersController.php | 2 +- app/Http/Requests/CategoryEmpRequest.php | 45 +++++ app/Http/Requests/EducationRequest.php | 45 +++++ app/Models/Education.php | 20 +++ app/Providers/MyServiceProvider.php | 4 +- .../2023_10_03_114608_create_education_table.php | 33 ++++ .../2023_10_03_114801_alter_table_workers.php | 32 ++++ resources/views/admin/education/add.blade.php | 7 + resources/views/admin/education/edit.blade.php | 7 + resources/views/admin/education/form.blade.php | 32 ++++ resources/views/admin/education/index.blade.php | 61 +++++++ resources/views/admin/employer/edit.blade.php | 31 ++++ resources/views/admin/employer/index.blade.php | 22 ++- resources/views/admin/index.blade.php | 55 ++++++- resources/views/admin/message/index.blade.php | 18 +- resources/views/admin/message/index2.blade.php | 174 ++++++++++++++++++++ resources/views/admin/message/index_ajax.blade.php | 15 +- resources/views/admin/messages.blade.php | 8 + resources/views/layout/admin.blade.php | 18 +- routes/web.php | 6 + 26 files changed, 736 insertions(+), 31 deletions(-) create mode 100644 app/Http/Controllers/Admin/EducationController.php create mode 100644 app/Http/Requests/CategoryEmpRequest.php create mode 100644 app/Http/Requests/EducationRequest.php create mode 100644 app/Models/Education.php create mode 100644 database/migrations/2023_10_03_114608_create_education_table.php create mode 100644 database/migrations/2023_10_03_114801_alter_table_workers.php create mode 100644 resources/views/admin/education/add.blade.php create mode 100644 resources/views/admin/education/edit.blade.php create mode 100644 resources/views/admin/education/form.blade.php create mode 100644 resources/views/admin/education/index.blade.php create mode 100644 resources/views/admin/message/index2.blade.php 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') +
+ @include('admin.education.form') +
+@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') +
+ @include('admin.education.form') +
+@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 + +
+
+ +
+
+ + Назад +
+
+
diff --git a/resources/views/admin/education/index.blade.php b/resources/views/admin/education/index.blade.php new file mode 100644 index 0000000..4caa35b --- /dev/null +++ b/resources/views/admin/education/index.blade.php @@ -0,0 +1,61 @@ +@extends('layout.admin', ['title' => 'Админка - Справочник образование']) + +@section('script') + +@endsection + +@section('search') + +@endsection + +@section('content') + + + Добавить образование + +
+
+ +
+ + + + + + + + + + + @foreach($education 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 5541976..79877d6 100644 --- a/resources/views/admin/employer/edit.blade.php +++ b/resources/views/admin/employer/edit.blade.php @@ -107,6 +107,37 @@ >{{ old('text') ?? $employer->text ?? '' }} +
+ + + + +
-

Пользователи

+

+ @if ($UserId == 1) + Пользователи + @else + Пользователи + @endif +

- Все пользователи сайта + Все пользователи сайта. Управление ими. Только для разработчика!

@@ -114,8 +120,8 @@ users - - Доступно + + Недоступно + + + + + + {{$msg->title}} +
+ +
+ + + {{ $msg->created_at }} + + + @if (($msg->user_to->id == $id_admin) && ($msg->flag_new == 1)) + + @endif + + + @endforeach + + + + +
+ appends($_GET)->links('admin.pagginate'); ?> +
+
+ +
+ +
+ @csrf +
+

Отправка сообщения

+
+
+ +
+ +
+ + +
+ +
+
+ +
+
+
+
+
+@endsection diff --git a/resources/views/admin/message/index_ajax.blade.php b/resources/views/admin/message/index_ajax.blade.php index c2a974e..b99c8d2 100644 --- a/resources/views/admin/message/index_ajax.blade.php +++ b/resources/views/admin/message/index_ajax.blade.php @@ -15,15 +15,26 @@ @foreach($Msgs as $msg) user_to->id == $id_admin) && ($msg->flag_new == 1)) style="background-color: #403998;" @endif> + @if (isset($msg->user_to->id)) + @if (($msg->user_to->id == $id_admin) && ($msg->flag_new == 1)) style="background-color: #403998;" + @endif + @endif> {{$msg->id}} + @if ((isset($msg->user_from->name)) && (!empty($msg->user_from->name))) {{$msg->user_from->name}} ({{$msg->user_from->id}}) + @else + Пользователь удален + @endif + @if ((isset($msg->user_to->name)) && (!empty($msg->user_to->name))) {{$msg->user_to->name}} ({{$msg->user_to->id}}) + @else + Пользователь удален + @endif {{$msg->title}} @@ -35,9 +46,11 @@ {{ $msg->created_at }} + @if (isset($msg->user_to->id)) @if (($msg->user_to->id == $id_admin) && ($msg->flag_new == 1)) @endif + @endif @endforeach diff --git a/resources/views/admin/messages.blade.php b/resources/views/admin/messages.blade.php index 0753786..ddca914 100644 --- a/resources/views/admin/messages.blade.php +++ b/resources/views/admin/messages.blade.php @@ -55,10 +55,18 @@ {{$msg->id}} + @if (isset($msg->user_from->id)) {{$msg->user_from->name}} ({{$msg->user_from->id}}) + @else + Пользователь удален + @endif + @if (isset($msg->user_to->id)) {{$msg->user_to->name}} ({{$msg->user_to->id}}) + @else + Пользователь удален + @endif {{$msg->title}} diff --git a/resources/views/layout/admin.blade.php b/resources/views/layout/admin.blade.php index 27b9ff0..890a637 100644 --- a/resources/views/layout/admin.blade.php +++ b/resources/views/layout/admin.blade.php @@ -61,6 +61,7 @@