From 7e815b9c0bb873fefa7f2b2003555a06a2191c0e Mon Sep 17 00:00:00 2001 From: Thekindbull Date: Fri, 11 Apr 2025 13:02:02 +0800 Subject: [PATCH] adminka updated --- .../Controllers/Company/DetailsController.php | 57 +++++++------- app/Models/Company/CompanyStatus.php | 8 ++ .../Controllers/AdminCompaniesController.php | 15 +++- .../Controllers/AdminComplexesController.php | 3 +- .../Admin/Views/cities/index.blade.php | 3 +- .../Admin/Views/companies/edit.blade.php | 1 + .../Admin/Views/companies/index.blade.php | 32 +++++++- .../Admin/Views/complexes/edit.blade.php | 77 +++++++++++++++++++ .../Admin/Views/complexes/index.blade.php | 3 +- app/Modules/Admin/Views/menu/index.blade.php | 4 +- .../Admin/Views/payments/index.blade.php | 2 +- .../Admin/Views/posts/create.blade.php | 1 + app/Modules/Admin/Views/posts/edit.blade.php | 1 + app/Modules/Admin/Views/posts/index.blade.php | 1 + app/Modules/Admin/Views/users/edit.blade.php | 3 +- app/Modules/Admin/Views/users/index.blade.php | 7 +- lang/ru.json | 10 ++- resources/views/layouts/admin.blade.php | 55 ++++++------- resources/views/layouts/app.blade.php | 54 ++++++------- routes/web.php | 3 +- 20 files changed, 233 insertions(+), 107 deletions(-) create mode 100644 app/Models/Company/CompanyStatus.php create mode 100644 app/Modules/Admin/Views/complexes/edit.blade.php diff --git a/app/Http/Controllers/Company/DetailsController.php b/app/Http/Controllers/Company/DetailsController.php index 42306a9..6f3e5ee 100644 --- a/app/Http/Controllers/Company/DetailsController.php +++ b/app/Http/Controllers/Company/DetailsController.php @@ -9,64 +9,69 @@ use App\Models\Company\Details; use App\Models\Company\CompanyAdmin; use App\Models\Company\CompanyType; - class DetailsController extends Controller +{ + public function index($companyId = null) { - public function index() - { $company = false; - $userId = auth()->user()->id; - $admin = CompanyAdmin::where('user_id', $userId)->get(); - if ($admin->count() == 1) + if (!$companyId) + { + $userId = auth()->user()->id; + $admin = CompanyAdmin::where('user_id', $userId); + if ($admin->count() == 1) { - $agent = $admin->first(); - $company = Company::find($agent->company_id); + $agent = $admin->first(); + $company = Company::find($agent->company_id); } + else + { + abort(code: 401); + } + } else - { - abort(code: 401); - } - ; + { + $company = Company::find($companyId); + } $details = new Details($company); $details = $details->details; if ($company->type == CompanyType::SelfEmployer || $company->type == CompanyType::SoleProperty) - { + { return view('company.details.selfemp', [ 'company' => $company, 'details' => $details ]); - } + } ; if ($company->type == CompanyType::Agency) - { + { return view('company.details.agency', [ 'company' => $company, 'details' => $details ]); - } - ; } + ; + } public function store(Request $request, Company $company) - { + { $userId = auth()->user()->id; $admin = CompanyAdmin::where('user_id', $userId)->get(); if ($admin->count() == 1) - { + { $agent = $admin->first(); if ($agent->company_id != $company->id) - { - return; - } - } - else { - return back(); + return; } + } + else + { + return back(); + } $company->details = $request->all(); $company->save(); return to_route('company.details', [ 'company' => $company ]); - } } +} diff --git a/app/Models/Company/CompanyStatus.php b/app/Models/Company/CompanyStatus.php new file mode 100644 index 0000000..d4463c5 --- /dev/null +++ b/app/Models/Company/CompanyStatus.php @@ -0,0 +1,8 @@ +get(); + $companies = Company::orderBy('name'); + //if ($request->filter) { + if (!(!$request->filter || $request->filter == 'all')) + { + $companies->where('status', $request->filter); + } + $companies = $companies->get(); return view('admin::companies.index', [ - 'companies' => $companies + 'companies' => $companies, + 'statuses' => CompanyStatus::cases(), + 'filter' => $request->filter ]); } public function edit(Company $company) diff --git a/app/Modules/Admin/Http/Controllers/AdminComplexesController.php b/app/Modules/Admin/Http/Controllers/AdminComplexesController.php index e149344..a05abc0 100644 --- a/app/Modules/Admin/Http/Controllers/AdminComplexesController.php +++ b/app/Modules/Admin/Http/Controllers/AdminComplexesController.php @@ -12,7 +12,6 @@ class AdminComplexesController extends Controller public function index(Request $request) { $complexes = Complex::orderBy('name'); - //if ($request->filter) { switch ( $request->filter ) { case 'trashed': @@ -33,7 +32,7 @@ public function index(Request $request) } public function edit(Complex $complex) { - return view('admin::companies.edit', [ + return view('admin::complexes.edit', [ 'complex' => $complex, ]); } diff --git a/app/Modules/Admin/Views/cities/index.blade.php b/app/Modules/Admin/Views/cities/index.blade.php index c2ad165..13a6bf7 100644 --- a/app/Modules/Admin/Views/cities/index.blade.php +++ b/app/Modules/Admin/Views/cities/index.blade.php @@ -1,7 +1,6 @@ +@php($title = 'Города') @extends('layouts.admin') @section('content') -

Города

-
diff --git a/app/Modules/Admin/Views/companies/index.blade.php b/app/Modules/Admin/Views/companies/index.blade.php index 5d5ae51..ba0b046 100644 --- a/app/Modules/Admin/Views/companies/index.blade.php +++ b/app/Modules/Admin/Views/companies/index.blade.php @@ -1,6 +1,26 @@ +@php($title = 'Агентства') @extends('layouts.admin') @section('content')
+
+ + + + @foreach ($statuses as $status) + value ? 'checked' : '' }}> + + @endforeach + +
+ +
+
@if ($companies->count() == 0)
Нет данных для отображения
@else @@ -9,7 +29,9 @@ Название - + ИНН + Email + Статус @@ -21,7 +43,13 @@ {{ $company->name }} - + {{ $company->inn }} + + + {{ $company->email }} + + + {{ __('Status ' . $company->status) }} diff --git a/app/Modules/Admin/Views/complexes/edit.blade.php b/app/Modules/Admin/Views/complexes/edit.blade.php new file mode 100644 index 0000000..464f2d6 --- /dev/null +++ b/app/Modules/Admin/Views/complexes/edit.blade.php @@ -0,0 +1,77 @@ +@php($title = 'Жилые комплексы') +@extends('layouts.admin') +@section('content') +
+

Жилой комплекс

+
+ @csrf +
+ + + @error('name') +
{{ $message }}
+ @enderror +
+
+
+ + + @error('email') +
{{ $message }}
+ @enderror +
+
+ + + @error('phone') +
{{ $message }}
+ @enderror +
+
+ +
+
+ +
+

Роли пользователя

+ + + + + + + @foreach ($userRoles as $userRole) + + + + + + @endforeach + +
Роль + Когда назначена + +
+ {{ __($userRole->role->name) }} + + {{ $userRole->created_at->diffForHumans() }} + + +
+
+@endsection diff --git a/app/Modules/Admin/Views/complexes/index.blade.php b/app/Modules/Admin/Views/complexes/index.blade.php index a50143e..5467db6 100644 --- a/app/Modules/Admin/Views/complexes/index.blade.php +++ b/app/Modules/Admin/Views/complexes/index.blade.php @@ -1,7 +1,6 @@ +@php($title = 'Жилые комплексы') @extends('layouts.admin') @section('content') -

Жилые комплексы

-
@if (in_array($roles::SUPER_ADMIN, $userRoles)) -