fix! admin intarface bugs
This commit is contained in:
parent
c4fa64ce61
commit
4dae0ab1fa
@ -10,7 +10,6 @@ class AdminCitiesController extends Controller
|
|||||||
public function index(Request $request)
|
public function index(Request $request)
|
||||||
{
|
{
|
||||||
$cities = City::orderBy('name');
|
$cities = City::orderBy('name');
|
||||||
//if ($request->filter) {
|
|
||||||
switch ( $request->filter )
|
switch ( $request->filter )
|
||||||
{
|
{
|
||||||
case 'trashed':
|
case 'trashed':
|
||||||
|
|||||||
@ -35,7 +35,8 @@ public function edit(Complex $complex)
|
|||||||
{
|
{
|
||||||
return view('admin::complexes.edit', [
|
return view('admin::complexes.edit', [
|
||||||
'complex' => $complex,
|
'complex' => $complex,
|
||||||
'cities' => City::orderBy('name')->get()
|
'cities' => City::orderBy('name')->get(),
|
||||||
|
'backUrl' => route(name: 'admin.complexes')
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -14,7 +14,9 @@ public function index()
|
|||||||
{
|
{
|
||||||
return $this->goToSuperAdminCreator();
|
return $this->goToSuperAdminCreator();
|
||||||
}
|
}
|
||||||
return view('admin::index');
|
return view('admin::index', [
|
||||||
|
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function superAdminExists()
|
public function superAdminExists()
|
||||||
|
|||||||
@ -11,6 +11,8 @@
|
|||||||
use Modules\User\Models\UserRole;
|
use Modules\User\Models\UserRole;
|
||||||
use Modules\User\Models\Role;
|
use Modules\User\Models\Role;
|
||||||
use Modules\User\Models\User;
|
use Modules\User\Models\User;
|
||||||
|
use Modules\Main\Models\Company\CompanyAdmin;
|
||||||
|
use Modules\Main\Models\Agent\Agent;
|
||||||
|
|
||||||
class AdminUsersController extends Controller
|
class AdminUsersController extends Controller
|
||||||
{
|
{
|
||||||
@ -41,7 +43,10 @@ public function edit(User $user)
|
|||||||
return view('admin::users.edit', [
|
return view('admin::users.edit', [
|
||||||
'user' => $user,
|
'user' => $user,
|
||||||
'userRoles' => $roles,
|
'userRoles' => $roles,
|
||||||
'roles' => Role::class
|
'roles' => Role::class,
|
||||||
|
'companyAdmins' => CompanyAdmin::where('user_id', $user->id)->get(),
|
||||||
|
'companyAgents' => Agent::where('user_id', $user->id)->get(),
|
||||||
|
'backUrl' => route(name: 'admin.users')
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
public function store(Request $request)
|
public function store(Request $request)
|
||||||
@ -52,6 +57,18 @@ public function store(Request $request)
|
|||||||
return to_route('admin.users')->withSuccess('Учетная запись для ' . $request->name . ' создана. Пароль пользователя: ' . $password);
|
return to_route('admin.users')->withSuccess('Учетная запись для ' . $request->name . ' создана. Пароль пользователя: ' . $password);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function delete(Request $request, User $user)
|
||||||
|
{
|
||||||
|
if ($request->confirmed) {
|
||||||
|
$user->delete();
|
||||||
|
return to_route('admin.users');
|
||||||
|
} else {
|
||||||
|
return view('admin::users.confirm-delete',
|
||||||
|
['user' => $user]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return to_route('admin.users');
|
||||||
|
}
|
||||||
public function update(Request $request, User $user)
|
public function update(Request $request, User $user)
|
||||||
{
|
{
|
||||||
$user->update($request->only('name', 'email', 'phone'));
|
$user->update($request->only('name', 'email', 'phone'));
|
||||||
|
|||||||
43
app/Modules/Admin/Views/users/confirm-delete.blade.php
Normal file
43
app/Modules/Admin/Views/users/confirm-delete.blade.php
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
@php($title = 'Пользователи')
|
||||||
|
@extends('layouts.admin')
|
||||||
|
@section('content')
|
||||||
|
<div>
|
||||||
|
<div class="alert alert-danger align-items-center text-center" role="alert">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" fill="currentColor"
|
||||||
|
class="bi bi-exclamation-triangle-fill" viewBox="0 0 16 16">
|
||||||
|
<path
|
||||||
|
d="M8.982 1.566a1.13 1.13 0 0 0-1.96 0L.165 13.233c-.457.778.091 1.767.98 1.767h13.713c.889 0 1.438-.99.98-1.767zM8 5c.535 0 .954.462.9.995l-.35 3.507a.552.552 0 0 1-1.1 0L7.1 5.995A.905.905 0 0 1 8 5m.002 6a1 1 0 1 1 0 2 1 1 0 0 1 0-2" />
|
||||||
|
</svg>
|
||||||
|
<div class="my-3 fs-5">
|
||||||
|
Вы удаляете пользователя <b>{{ $user->name }}</b>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@if(count($user->roles) > 0)
|
||||||
|
<div class="my-2">
|
||||||
|
<div>
|
||||||
|
Проверьте назначенные данному пользователю права, которые будут аннулированы:
|
||||||
|
</div>
|
||||||
|
<div class="d-flex gap-2 justify-content-center">
|
||||||
|
@foreach($user->roles as $role)
|
||||||
|
<div class=""><b>{{ __($role->name) }}</b></div>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
<div class="my-5">
|
||||||
|
<div class="hstack gap-3 justify-content-center">
|
||||||
|
<form method="post" action="{{ route('admin.users.delete', [
|
||||||
|
'user' => $user,
|
||||||
|
'confirmed' => true
|
||||||
|
]) }}
|
||||||
|
">
|
||||||
|
@csrf
|
||||||
|
<button class="btn btn-danger" type="submit">Продолжить удаление</button>
|
||||||
|
</form>
|
||||||
|
<a class="btn btn-light" href="{{ url()->previous() }}">Отмена</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endsection
|
||||||
@ -48,6 +48,20 @@
|
|||||||
<tr scope="row">
|
<tr scope="row">
|
||||||
<td class="align-middle">
|
<td class="align-middle">
|
||||||
{{ __($userRole->role->name) }}
|
{{ __($userRole->role->name) }}
|
||||||
|
@if($userRole->role->id == $roles::COMPANY_ADMIN)
|
||||||
|
<div class="fs-6 hstack gap-1">
|
||||||
|
@foreach($companyAdmins as $admin)
|
||||||
|
<span class="badge text-bg-secondary">{{ $admin->company->name }}</span>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
@if($userRole->role->id == $roles::AGENT)
|
||||||
|
<div class="fs-6 hstack gap-1">
|
||||||
|
@foreach($companyAgents as $agent)
|
||||||
|
<span class="badge text-bg-secondary">{{ $agent->company->name }}</span>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
</td>
|
</td>
|
||||||
<td class="align-middle">
|
<td class="align-middle">
|
||||||
{{ $userRole->created_at?->diffForHumans() }}
|
{{ $userRole->created_at?->diffForHumans() }}
|
||||||
|
|||||||
@ -2,9 +2,7 @@
|
|||||||
@extends('layouts.admin')
|
@extends('layouts.admin')
|
||||||
@section('content')
|
@section('content')
|
||||||
<div>
|
<div>
|
||||||
@if ($users->count() == 0)
|
|
||||||
<div class="text-center py-5">Нет данных для отображения</div>
|
|
||||||
@else
|
|
||||||
<form class="d-flex mb-3" method="GET" action="{{ route('admin.users') }}">
|
<form class="d-flex mb-3" method="GET" action="{{ route('admin.users') }}">
|
||||||
<div class="p-2 border rounded-3 border-1 bg-white">
|
<div class="p-2 border rounded-3 border-1 bg-white">
|
||||||
<input type="radio" class="btn-check" name="role" value="all" id="option_all" autocomplete="off"
|
<input type="radio" class="btn-check" name="role" value="all" id="option_all" autocomplete="off"
|
||||||
@ -25,7 +23,9 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
@if ($users->count() == 0)
|
||||||
|
<div class="text-center py-5">Нет данных для отображения</div>
|
||||||
|
@else
|
||||||
<div class="fs-5 bg-light p-0 m-0 border border-1 rounded-4 py-3">
|
<div class="fs-5 bg-light p-0 m-0 border border-1 rounded-4 py-3">
|
||||||
<table class="table m-0">
|
<table class="table m-0">
|
||||||
<thead>
|
<thead>
|
||||||
@ -62,7 +62,7 @@
|
|||||||
<a class="dropdown-item"
|
<a class="dropdown-item"
|
||||||
href="{{ route('admin.users.edit', ['user' => $user]) }}">Редактировать</a>
|
href="{{ route('admin.users.edit', ['user' => $user]) }}">Редактировать</a>
|
||||||
<form method="post"
|
<form method="post"
|
||||||
action="{{ route('admin.posts.delete', ['post' => $user]) }}">
|
action="{{ route('admin.users.delete', ['user' => $user]) }}">
|
||||||
@csrf
|
@csrf
|
||||||
<button class="dropdown-item" type="submit">Удалить</button>
|
<button class="dropdown-item" type="submit">Удалить</button>
|
||||||
</form>
|
</form>
|
||||||
@ -75,6 +75,7 @@
|
|||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
@livewire('post.card')
|
@livewire('post.card')
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -85,7 +86,7 @@
|
|||||||
enctype="multipart/form-data">
|
enctype="multipart/form-data">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
<h1 class="modal-title fs-5" id="createUserModalLabel">Загрузка документа</h1>
|
<h1 class="modal-title fs-5" id="createUserModalLabel">Новый пользователь</h1>
|
||||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
|
|||||||
@ -32,5 +32,15 @@ protected static function booted()
|
|||||||
'role_id' => Role::CITY_MANAGER
|
'role_id' => Role::CITY_MANAGER
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
static::deleted(function (CityManager $cityManager)
|
||||||
|
{
|
||||||
|
if (CityManager::where('user_id', $cityManager->user->id)->count() == 0) {
|
||||||
|
UserRole::where([
|
||||||
|
'user_id' => $cityManager->user_id,
|
||||||
|
'role_id' => Role::CITY_MANAGER
|
||||||
|
])->delete();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration {
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('company_admins', function (Blueprint $table) {
|
||||||
|
$table->dropForeign(['user_id']);
|
||||||
|
$table->dropForeign(['company_id']);
|
||||||
|
$table->foreign('user_id')
|
||||||
|
->references('id')->on('users')
|
||||||
|
->onDelete('cascade');
|
||||||
|
$table->foreign('company_id')
|
||||||
|
->references('id')->on('companies')
|
||||||
|
->onDelete('cascade');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('company_admins', function (Blueprint $table) {
|
||||||
|
$table->dropForeign(['user_id']);
|
||||||
|
$table->dropForeign(['company_id']);
|
||||||
|
|
||||||
|
$table->foreign('user_id')
|
||||||
|
->references('id')->on('users');
|
||||||
|
$table->foreign('company_id')
|
||||||
|
->references('id')->on('companies');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration {
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('agents', function (Blueprint $table) {
|
||||||
|
$table->dropForeign(['user_id']);
|
||||||
|
$table->dropForeign(['company_id']);
|
||||||
|
$table->foreign('user_id')
|
||||||
|
->references('id')->on('users')
|
||||||
|
->onDelete('cascade');
|
||||||
|
$table->foreign('company_id')
|
||||||
|
->references('id')->on('companies')
|
||||||
|
->onDelete('cascade');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('agents', function (Blueprint $table) {
|
||||||
|
$table->dropForeign(['user_id']);
|
||||||
|
$table->dropForeign(['company_id']);
|
||||||
|
$table->foreign('user_id')
|
||||||
|
->references('id')->on('users');
|
||||||
|
$table->foreign('company_id')
|
||||||
|
->references('id')->on('companies');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@ -60,6 +60,32 @@ function GetAvailableAgents($resultType = 'Collection')
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!function_exists('GetAvailableCompanies')) {
|
||||||
|
function GetAvailableCompanies($resultType = 'Collection')
|
||||||
|
{
|
||||||
|
$companiesIds = [];
|
||||||
|
if ($adminCompany = AdminCompanyOfUser()) {
|
||||||
|
$companiesIds[] = $adminCompany->id;
|
||||||
|
}
|
||||||
|
if ($cityManager = CityManager::where('user_id', auth()->user()->id)) {
|
||||||
|
if ($cityManager->count()) {
|
||||||
|
$companies = Company::whereIn('city_id', $cityManager->pluck('city_id'));
|
||||||
|
if ($companies->count()) {
|
||||||
|
$companies = $companies->get()->pluck('id');
|
||||||
|
$companiesIds = array_merge($companiesIds, $companies->all());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$companiesIds = array_unique($companiesIds);
|
||||||
|
$companies = Company::whereIn('id', $companiesIds);
|
||||||
|
if ($resultType == 'Collection') {
|
||||||
|
return $companies->get();
|
||||||
|
} else {
|
||||||
|
return $companies;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!function_exists('GetAvailableComplexes')) {
|
if (!function_exists('GetAvailableComplexes')) {
|
||||||
function GetAvailableComplexes()
|
function GetAvailableComplexes()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -15,7 +15,8 @@ class CreateAgentLivewire extends Component
|
|||||||
public function mount($containerId = 'createAgentModal')
|
public function mount($containerId = 'createAgentModal')
|
||||||
{
|
{
|
||||||
$this->containerId = $containerId;
|
$this->containerId = $containerId;
|
||||||
$availableCompaniesIds = GetAvailableAgents('Builder')->pluck('company_id');
|
$availableCompaniesIds = GetAvailableCompanies('Collection')->pluck('id');
|
||||||
|
|
||||||
$this->availableCompanies = Company::whereIn('id', $availableCompaniesIds)->get();
|
$this->availableCompanies = Company::whereIn('id', $availableCompaniesIds)->get();
|
||||||
if ($this->availableCompanies->count() == 1) {
|
if ($this->availableCompanies->count() == 1) {
|
||||||
$this->companyId = $this->availableCompanies->first()->id;
|
$this->companyId = $this->availableCompanies->first()->id;
|
||||||
|
|||||||
@ -42,6 +42,7 @@
|
|||||||
"Company admin": "Администратор агентства",
|
"Company admin": "Администратор агентства",
|
||||||
"Agent": "Агент",
|
"Agent": "Агент",
|
||||||
"Client": "Клиент",
|
"Client": "Клиент",
|
||||||
|
"City manager": "Региональный менеджер",
|
||||||
"Status new": "Новый",
|
"Status new": "Новый",
|
||||||
"Status moderation": "Модерация",
|
"Status moderation": "Модерация",
|
||||||
"Status accepted": "Одобрен",
|
"Status accepted": "Одобрен",
|
||||||
|
|||||||
@ -27,7 +27,7 @@
|
|||||||
<img src={{ url('/images/logo.png') }} alt="Logo" width="70">
|
<img src={{ url('/images/logo.png') }} alt="Logo" width="70">
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="col px-0 px-md-4 text-start" id="pageTitle">
|
<div class="col px-0 px-md-4 text-start align-middle" id="pageTitle">
|
||||||
<a class="icon-link icon-link-hover text-truncate fw-lighter fs-4 text-secondary text-uppercase text-decoration-none align-middle"
|
<a class="icon-link icon-link-hover text-truncate fw-lighter fs-4 text-secondary text-uppercase text-decoration-none align-middle"
|
||||||
href="@isset($backUrl) {{ $backUrl }} @endisset"
|
href="@isset($backUrl) {{ $backUrl }} @endisset"
|
||||||
style="--bs-icon-link-transform: translate3d(-.125rem, 0, 0);">
|
style="--bs-icon-link-transform: translate3d(-.125rem, 0, 0);">
|
||||||
@ -93,6 +93,26 @@ class="bi bi-caret-left" viewBox="0 0 16 16">
|
|||||||
@livewire('admin.menu')
|
@livewire('admin.menu')
|
||||||
</div>
|
</div>
|
||||||
<div class="col-10 px-0 px-md-4">
|
<div class="col-10 px-0 px-md-4">
|
||||||
|
<nav aria-label="breadcrumb">
|
||||||
|
<ol class="breadcrumb">
|
||||||
|
<li class="breadcrumb-item">
|
||||||
|
<a class="icon-link"
|
||||||
|
href="{{ route('home') }}">
|
||||||
|
<i class="bi bi-house-door-fill"></i>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li class="breadcrumb-item"><a href="{{ route('admin.index') }}">Админка</a></li>
|
||||||
|
@isset($title)
|
||||||
|
<li class="breadcrumb-item active" aria-current="page">
|
||||||
|
<a class=""
|
||||||
|
href="@isset($backUrl) {{ $backUrl }} @endisset"
|
||||||
|
style="">
|
||||||
|
{{ $title }}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
@endisset
|
||||||
|
</ol>
|
||||||
|
</nav>
|
||||||
@if (session('success'))
|
@if (session('success'))
|
||||||
<div class="alert alert-success">
|
<div class="alert alert-success">
|
||||||
{{ session('success') }}
|
{{ session('success') }}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user