admin functionallity updated
This commit is contained in:
parent
30f124a429
commit
e31946e9ad
@ -4,8 +4,13 @@
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
class City extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'name'
|
||||
];
|
||||
}
|
||||
|
||||
@ -4,12 +4,14 @@
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Complex extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
public function city() {
|
||||
return $this->belongsTo(\App\Models\City::class, 'city_id');
|
||||
use SoftDeletes;
|
||||
public function city()
|
||||
{
|
||||
return $this->belongsTo(\App\Models\City::class, 'city_id')->withTrashed();
|
||||
}
|
||||
}
|
||||
|
||||
@ -8,11 +8,16 @@
|
||||
use App\Models\User\Role;
|
||||
|
||||
class UserRole extends Model
|
||||
{
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'role_id',
|
||||
];
|
||||
|
||||
public function role()
|
||||
{
|
||||
return $this->belongsTo(Role::class, 'role_id');
|
||||
}
|
||||
}
|
||||
|
||||
65
app/Modules/Admin/Http/Controllers/AdminCitiesController.php
Normal file
65
app/Modules/Admin/Http/Controllers/AdminCitiesController.php
Normal file
@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Admin\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
use App\Models\City;
|
||||
|
||||
class AdminCitiesController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$cities = City::orderBy('name');
|
||||
//if ($request->filter) {
|
||||
switch ( $request->filter )
|
||||
{
|
||||
case 'trashed':
|
||||
$cities->onlyTrashed();
|
||||
break;
|
||||
case 'actual':
|
||||
break;
|
||||
default:
|
||||
$cities->withTrashed();
|
||||
break;
|
||||
}
|
||||
//}
|
||||
$cities = $cities->get();
|
||||
return view('admin::cities.index', [
|
||||
'cities' => $cities,
|
||||
'filter' => $request->filter
|
||||
]);
|
||||
}
|
||||
public function edit(City $city)
|
||||
{
|
||||
return view('admin::companies.edit', [
|
||||
'city' => $city,
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(Request $request, City $city)
|
||||
{
|
||||
$city->update($request->only('name'));
|
||||
return to_route('admin.companies');
|
||||
}
|
||||
|
||||
public function create(Request $request)
|
||||
{
|
||||
$city = City::create($request->only('name'));
|
||||
return to_route('admin.cities');
|
||||
}
|
||||
|
||||
public function delete(City $city)
|
||||
{
|
||||
$city->delete();
|
||||
return to_route('admin.cities');
|
||||
}
|
||||
|
||||
public function restore(City $city)
|
||||
{
|
||||
$city->restore();
|
||||
return to_route('admin.cities');
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Admin\Http\Controllers;
|
||||
|
||||
use Modules\Post\Models\Post;
|
||||
use Modules\Post\Models\PostCategory;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
use App\Models\Company\Company;
|
||||
|
||||
class AdminCompaniesController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$companies = Company::orderBy('name')->get();
|
||||
return view('admin::companies.index', [
|
||||
'companies' => $companies
|
||||
]);
|
||||
}
|
||||
public function edit(Company $company)
|
||||
{
|
||||
return view('admin::companies.edit', [
|
||||
'company' => $company,
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(Request $request, Company $company)
|
||||
{
|
||||
$company->update($request->only('name', 'email', 'phone'));
|
||||
return to_route('admin.companies');
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Admin\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
use App\Models\Complex;
|
||||
|
||||
class AdminComplexesController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$complexes = Complex::orderBy('name');
|
||||
//if ($request->filter) {
|
||||
switch ( $request->filter )
|
||||
{
|
||||
case 'trashed':
|
||||
$complexes->onlyTrashed();
|
||||
break;
|
||||
case 'actual':
|
||||
break;
|
||||
default:
|
||||
$complexes->withTrashed();
|
||||
break;
|
||||
}
|
||||
//}
|
||||
$complexes = $complexes->get();
|
||||
return view('admin::complexes.index', [
|
||||
'complexes' => $complexes,
|
||||
'filter' => $request->filter
|
||||
]);
|
||||
}
|
||||
public function edit(Complex $complex)
|
||||
{
|
||||
return view('admin::companies.edit', [
|
||||
'complex' => $complex,
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(Request $request, Complex $complex)
|
||||
{
|
||||
$complex->update($request->only('name'));
|
||||
return to_route('admin.complexes');
|
||||
}
|
||||
|
||||
public function create(Request $request)
|
||||
{
|
||||
$city = Complex::create($request->only('name'));
|
||||
return to_route('admin.complexes');
|
||||
}
|
||||
|
||||
public function delete(Complex $complex)
|
||||
{
|
||||
$complex->delete();
|
||||
return to_route('admin.complexes');
|
||||
}
|
||||
|
||||
public function restore(Complex $complex)
|
||||
{
|
||||
$complex->restore();
|
||||
return to_route('admin.complexes');
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Admin\Http\Controllers;
|
||||
|
||||
use Modules\Post\Models\Post;
|
||||
use Modules\Post\Models\PostCategory;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
use App\Models\Company\Company;
|
||||
use App\Models\Complex;
|
||||
|
||||
use App\Models\Agent\Agent;
|
||||
|
||||
class AdminPaymentsController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return view('admin::payments.index', [
|
||||
'companies' => Company::orderBy('name')->get(),
|
||||
'complexes' => Complex::orderBy('name')->get(),
|
||||
'agents' => Agent::all()
|
||||
]);
|
||||
}
|
||||
}
|
||||
62
app/Modules/Admin/Http/Controllers/AdminUsersController.php
Normal file
62
app/Modules/Admin/Http/Controllers/AdminUsersController.php
Normal file
@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Admin\Http\Controllers;
|
||||
|
||||
use Modules\Post\Models\Post;
|
||||
use Modules\Post\Models\PostCategory;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
use App\Models\User\UserRole;
|
||||
use App\Models\User\Role;
|
||||
use App\Models\User;
|
||||
|
||||
class AdminUsersController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$users = User::orderBy('name');
|
||||
if ($request->role && $request->role != 'all')
|
||||
{
|
||||
$users->whereIn(
|
||||
'id',
|
||||
UserRole::where('role_id', $request->role)
|
||||
->get()
|
||||
->map(function (UserRole $userRole)
|
||||
{
|
||||
return $userRole->user_id;
|
||||
})
|
||||
);
|
||||
}
|
||||
return view('admin::users.index', [
|
||||
'users' => $users->get(),
|
||||
'roles' => Role::all(),
|
||||
'role' => $request->role
|
||||
]);
|
||||
}
|
||||
public function edit(User $user)
|
||||
{
|
||||
$roles = UserRole::where('user_id', $user->id)->get();
|
||||
return view('admin::users.edit', [
|
||||
'user' => $user,
|
||||
'userRoles' => $roles,
|
||||
'roles' => Role::class
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(Request $request, User $user)
|
||||
{
|
||||
$user->update($request->only('name', 'email', 'phone'));
|
||||
return to_route('admin.users');
|
||||
}
|
||||
|
||||
public function deleteUserRole(UserRole $userRole)
|
||||
{
|
||||
$user = User::find($userRole->user_id);
|
||||
$userRole->delete();
|
||||
return to_route('admin.users.edit', [
|
||||
'user' => $user
|
||||
]);
|
||||
}
|
||||
}
|
||||
@ -16,6 +16,31 @@
|
||||
|
||||
|
||||
Route::get('/admin', [Modules\Admin\Http\Controllers\AdminController::class, 'index'])->name('admin.index');
|
||||
|
||||
Route::get('/admin/users', [Modules\Admin\Http\Controllers\AdminUsersController::class, 'index'])->name('admin.users');
|
||||
Route::get('/admin/users/{user}/edit', [Modules\Admin\Http\Controllers\AdminUsersController::class, 'edit'])->name('admin.users.edit');
|
||||
Route::post('/admin/users/{user}/update', [Modules\Admin\Http\Controllers\AdminUsersController::class, 'update'])->name('admin.users.update');
|
||||
Route::post('/admin/user-role/{userRole}/delete', [Modules\Admin\Http\Controllers\AdminUsersController::class, 'deleteUserRole'])->name('admin.users.role.delete');
|
||||
|
||||
Route::get('/admin/companies', [Modules\Admin\Http\Controllers\AdminCompaniesController::class, 'index'])->name('admin.companies');
|
||||
Route::get('/admin/companies/{company}/edit', [Modules\Admin\Http\Controllers\AdminCompaniesController::class, 'edit'])->name('admin.companies.edit');
|
||||
Route::post('/admin/companies/{company}/update', [Modules\Admin\Http\Controllers\AdminUsersController::class, 'update'])->name('admin.companies.update');
|
||||
Route::post('/admin/companies/{company}/delete', [Modules\Admin\Http\Controllers\AdminUsersController::class, 'update'])->name('admin.companies.delete');
|
||||
|
||||
Route::get('/admin/cities', [Modules\Admin\Http\Controllers\AdminCitiesController::class, 'index'])->name('admin.cities');
|
||||
Route::get('/admin/cities/{city}/edit', [Modules\Admin\Http\Controllers\AdminCitiesController::class, 'edit'])->name('admin.cities.edit');
|
||||
Route::post('/admin/cities/create', [Modules\Admin\Http\Controllers\AdminCitiesController::class, 'create'])->name('admin.cities.create');
|
||||
Route::post('/admin/cities/{city}/delete', [Modules\Admin\Http\Controllers\AdminCitiesController::class, 'delete'])->name('admin.cities.delete');
|
||||
Route::post('/admin/cities/{city}/restore', [Modules\Admin\Http\Controllers\AdminCitiesController::class, 'restore'])->withTrashed()->name('admin.cities.restore');
|
||||
|
||||
Route::get('/admin/complexes', [Modules\Admin\Http\Controllers\AdminComplexesController::class, 'index'])->name('admin.complexes');
|
||||
Route::get('/admin/complexes/{complex}/edit', [Modules\Admin\Http\Controllers\AdminComplexesController::class, 'edit'])->name('admin.complexes.edit');
|
||||
Route::post('/admin/complexes/create', [Modules\Admin\Http\Controllers\AdminComplexesController::class, 'create'])->name('admin.complexes.create');
|
||||
Route::post('/admin/complexes/{complex}/delete', [Modules\Admin\Http\Controllers\AdminComplexesController::class, 'delete'])->name('admin.complexes.delete');
|
||||
Route::post('/admin/complexes/{complex}/restore', [Modules\Admin\Http\Controllers\AdminComplexesController::class, 'restore'])->withTrashed()->name('admin.complexes.restore');
|
||||
|
||||
Route::get('/admin/payments', [Modules\Admin\Http\Controllers\AdminPaymentsController::class, 'index'])->name('admin.payments');
|
||||
|
||||
Route::get('/admin/posts', [Modules\Admin\Http\Controllers\AdminPostsController::class, 'index'])->name('admin.posts');
|
||||
Route::get('/admin/posts/create', [Modules\Admin\Http\Controllers\AdminPostsController::class, 'create'])->name('admin.posts.create');
|
||||
Route::post('/admin/posts/store', [Modules\Admin\Http\Controllers\AdminPostsController::class, 'store'])->name('admin.posts.store');
|
||||
|
||||
106
app/Modules/Admin/Views/cities/index.blade.php
Normal file
106
app/Modules/Admin/Views/cities/index.blade.php
Normal file
@ -0,0 +1,106 @@
|
||||
@extends('layouts.admin')
|
||||
@section('content')
|
||||
<h1>Города</h1>
|
||||
|
||||
<div class="d-flex mb-3">
|
||||
<form class="p-2 border rounded-3 border-1 bg-white" method="GET" action="{{ route('admin.cities') }}">
|
||||
<input type="radio" class="btn-check" name="filter" value="all" id="option_all" autocomplete="off"
|
||||
onclick="this.form.submit()" {{ $filter == 'all' || !$filter ? 'checked' : '' }}>
|
||||
<label class="btn p-2 fs-5" for="option_all">Все</label>
|
||||
|
||||
<input type="radio" class="btn-check" name="filter" value="actual" id="option_actual" autocomplete="off"
|
||||
onclick="this.form.submit()" {{ $filter == 'actual' ? 'checked' : '' }}>
|
||||
<label class="btn p-2 fs-5" for="option_actual">Актуальные</label>
|
||||
|
||||
<input type="radio" class="btn-check" name="filter" value="trashed" id="option_trashed" autocomplete="off"
|
||||
onclick="this.form.submit()" {{ $filter == 'trashed' ? 'checked' : '' }}>
|
||||
<label class="btn p-2 fs-5" for="option_trashed">Удаленные</label>
|
||||
</form>
|
||||
|
||||
|
||||
<div class="ms-auto p-2">
|
||||
<button class="btn btn-primary py-2 px-3 fs-5" data-bs-toggle="modal" data-bs-target="#createCityModal">
|
||||
<i class="bi bi-plus"></i> Добавить город
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="fs-5 bg-light p-0 m-0 border border-1 rounded-4 py-3">
|
||||
<table class="table m-0">
|
||||
<thead>
|
||||
<tr scope="col">
|
||||
<th>Название</th>
|
||||
<th>Дата создания</th>
|
||||
<th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class=" ">
|
||||
@foreach ($cities as $city)
|
||||
<tr scope="row" class="@if ($city->trashed()) bg-secondary @endif">
|
||||
<td class="align-middle">
|
||||
{{ $city->name }}
|
||||
</td>
|
||||
<td>
|
||||
{{ $city->created_at ? $city->created_at->diffForHumans() : '' }}
|
||||
</td>
|
||||
<td class="text-end">
|
||||
<div class="dropdown" style="">
|
||||
<button class="btn btn-light" type="button" id="dropdownMenuButton"
|
||||
data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
@if ($city->trashed())
|
||||
<i class="bi bi-recycle"></i>
|
||||
@else
|
||||
<i class="bi bi-three-dots-vertical"></i>
|
||||
@endif
|
||||
</button>
|
||||
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
|
||||
@if ($city->trashed())
|
||||
<form method="post"
|
||||
action="{{ route('admin.cities.restore', ['city' => $city]) }}">
|
||||
@csrf
|
||||
<button class="dropdown-item" type="submit">Восстановить</button>
|
||||
</form>
|
||||
@else
|
||||
<a class="dropdown-item"
|
||||
href="{{ route('admin.cities.edit', ['city' => $city]) }}">Редактировать</a>
|
||||
<form method="post" action="{{ route('admin.cities.delete', ['city' => $city]) }}">
|
||||
@csrf
|
||||
<button class="dropdown-item" type="submit">Удалить</button>
|
||||
</form>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- Modal -->
|
||||
<div class="modal fade" id="createCityModal" tabindex="-1" aria-labelledby="createCityModalLabel" aria-hidden="true">
|
||||
|
||||
<form class="modal-dialog modal-dialog-centered" action="{{ route('admin.cities.create') }}" method="post">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h1 class="modal-title fs-5" id="createCityModalLabel">Новый город</h1>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
|
||||
<div class="my-3">
|
||||
@csrf
|
||||
<label for="cityNameInput" class="form-label">Введите название нового города</label>
|
||||
<input class="form-control" type="text" id="cityNameInput" name="name" required>
|
||||
@error('text')
|
||||
<div class="text-danger">{{ $message }}</div>
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="submit" class="btn btn-primary">Добавить</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
@endsection
|
||||
77
app/Modules/Admin/Views/companies/edit.blade.php
Normal file
77
app/Modules/Admin/Views/companies/edit.blade.php
Normal file
@ -0,0 +1,77 @@
|
||||
@extends('layouts.admin')
|
||||
@section('content')
|
||||
<div class="fs-5 bg-light p-0 m-0 border border-1 rounded-4 p-3">
|
||||
|
||||
<h4 class="fw-bold my-3">Редактировать данные пользователя</h4>
|
||||
<form action="{{ route('admin.companies.update', ['company' => $company]) }}" method="post"
|
||||
enctype="multipart/form-data">
|
||||
@csrf
|
||||
<div class="mb-3">
|
||||
<label for="nameFormControl" class="form-label">Название</label>
|
||||
<input type="text" class="form-control" id="nameFormControl" name="name" value="{{ $company->name }}">
|
||||
@error('name')
|
||||
<div class="text-danger">{{ $message }}</div>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="mb-3">
|
||||
<label for="emailFormControl" class="form-label">Email</label>
|
||||
<input type="text" class="form-control" id="emailFormControl" name="email"
|
||||
value="{{ $user->email }}">
|
||||
@error('email')
|
||||
<div class="text-danger">{{ $message }}</div>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="phoneFormControl" class="form-label">телефон</label>
|
||||
<input type="text" class="form-control" id="phoneFormControl" name="phone"
|
||||
value="{{ $user->phone }}">
|
||||
@error('phone')
|
||||
<div class="text-danger">{{ $message }}</div>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Сохранить</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="fs-5 bg-light p-0 m-0 border border-1 rounded-4 mt-3 pb-3">
|
||||
<h4 class="fw-bold m-3">Роли пользователя</h4>
|
||||
<table class="table m-0">
|
||||
<thead>
|
||||
<tr scope="col">
|
||||
<th>Роль
|
||||
<th>Когда назначена
|
||||
<th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class=" ">
|
||||
@foreach ($userRoles as $userRole)
|
||||
<tr scope="row">
|
||||
<td class="align-middle">
|
||||
{{ __($userRole->role->name) }}
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
{{ $userRole->created_at->diffForHumans() }}
|
||||
</td>
|
||||
<td class="text-end">
|
||||
<div class="dropdown" style="">
|
||||
<button class="btn btn-light" type="button" id="dropdownMenuButton"
|
||||
data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
<i class="bi bi-three-dots-vertical"></i>
|
||||
</button>
|
||||
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
|
||||
<form method="post"
|
||||
action="{{ route('admin.users.role.delete', ['userRole' => $userRole]) }}">
|
||||
@csrf
|
||||
<button class="dropdown-item" type="submit">Удалить</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@endsection
|
||||
54
app/Modules/Admin/Views/companies/index.blade.php
Normal file
54
app/Modules/Admin/Views/companies/index.blade.php
Normal file
@ -0,0 +1,54 @@
|
||||
@extends('layouts.admin')
|
||||
@section('content')
|
||||
<div>
|
||||
@if ($companies->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">
|
||||
<table class="table m-0">
|
||||
<thead>
|
||||
<tr scope="col">
|
||||
<th>Название
|
||||
<th>
|
||||
<th>
|
||||
<th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class=" ">
|
||||
@foreach ($companies as $company)
|
||||
<tr scope="row">
|
||||
<td class="align-middle">
|
||||
{{ $company->name }}
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
|
||||
</td>
|
||||
<td class="text-end">
|
||||
<div class="dropdown" style="">
|
||||
<button class="btn btn-light" type="button" id="dropdownMenuButton"
|
||||
data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
<i class="bi bi-three-dots-vertical"></i>
|
||||
</button>
|
||||
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
|
||||
<a class="dropdown-item"
|
||||
href="{{ route('admin.companies.edit', ['company' => $company]) }}">Редактировать</a>
|
||||
<form method="post"
|
||||
action="{{ route('admin.companies.delete', ['company' => $company]) }}">
|
||||
@csrf
|
||||
<button class="dropdown-item" type="submit">Удалить</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
@endsection
|
||||
111
app/Modules/Admin/Views/complexes/index.blade.php
Normal file
111
app/Modules/Admin/Views/complexes/index.blade.php
Normal file
@ -0,0 +1,111 @@
|
||||
@extends('layouts.admin')
|
||||
@section('content')
|
||||
<h1>Жилые комплексы</h1>
|
||||
|
||||
<div class="d-flex mb-3">
|
||||
<form class="p-2 border rounded-3 border-1 bg-white" method="GET" action="{{ route('admin.complexes') }}">
|
||||
<input type="radio" class="btn-check" name="filter" value="all" id="option_all" autocomplete="off"
|
||||
onclick="this.form.submit()" {{ $filter == 'all' || !$filter ? 'checked' : '' }}>
|
||||
<label class="btn p-2 fs-5" for="option_all">Все</label>
|
||||
|
||||
<input type="radio" class="btn-check" name="filter" value="actual" id="option_actual" autocomplete="off"
|
||||
onclick="this.form.submit()" {{ $filter == 'actual' ? 'checked' : '' }}>
|
||||
<label class="btn p-2 fs-5" for="option_actual">Актуальные</label>
|
||||
|
||||
<input type="radio" class="btn-check" name="filter" value="trashed" id="option_trashed" autocomplete="off"
|
||||
onclick="this.form.submit()" {{ $filter == 'trashed' ? 'checked' : '' }}>
|
||||
<label class="btn p-2 fs-5" for="option_trashed">Удаленные</label>
|
||||
</form>
|
||||
|
||||
|
||||
<div class="ms-auto p-2">
|
||||
<button class="btn btn-primary py-2 px-3 fs-5" data-bs-toggle="modal" data-bs-target="#createCityModal">
|
||||
<i class="bi bi-plus"></i> Добавить комплекс
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="fs-5 bg-light p-0 m-0 border border-1 rounded-4 py-3">
|
||||
<table class="table m-0">
|
||||
<thead>
|
||||
<tr scope="col">
|
||||
<th>Название</th>
|
||||
<th>Город</th>
|
||||
<th>Дата создания
|
||||
<th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class=" ">
|
||||
@foreach ($complexes as $complex)
|
||||
<tr scope="row" class="@if ($complex->trashed()) bg-secondary @endif">
|
||||
<td class="align-middle">
|
||||
{{ $complex->name }}
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
{{ $complex->city->name }}
|
||||
</td>
|
||||
<td>
|
||||
{{ $complex->created_at ? $complex->created_at->diffForHumans() : '' }}
|
||||
</td>
|
||||
<td class="text-end">
|
||||
<div class="dropdown" style="">
|
||||
<button class="btn btn-light" type="button" id="dropdownMenuButton"
|
||||
data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
@if ($complex->trashed())
|
||||
<i class="bi bi-recycle"></i>
|
||||
@else
|
||||
<i class="bi bi-three-dots-vertical"></i>
|
||||
@endif
|
||||
</button>
|
||||
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
|
||||
@if ($complex->trashed())
|
||||
<form method="post"
|
||||
action="{{ route('admin.complexes.restore', ['complex' => $complex]) }}">
|
||||
@csrf
|
||||
<button class="dropdown-item" type="submit">Восстановить</button>
|
||||
</form>
|
||||
@else
|
||||
<a class="dropdown-item"
|
||||
href="{{ route('admin.complexes.edit', ['complex' => $complex]) }}">Редактировать</a>
|
||||
<form method="post"
|
||||
action="{{ route('admin.complexes.delete', ['complex' => $complex]) }}">
|
||||
@csrf
|
||||
<button class="dropdown-item" type="submit">Удалить</button>
|
||||
</form>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- Modal -->
|
||||
<div class="modal fade" id="createCityModal" tabindex="-1" aria-labelledby="createCityModalLabel" aria-hidden="true">
|
||||
|
||||
<form class="modal-dialog modal-dialog-centered" action="{{ route('admin.cities.create') }}" method="post">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h1 class="modal-title fs-5" id="createCityModalLabel">Новый город</h1>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
|
||||
<div class="my-3">
|
||||
@csrf
|
||||
<label for="cityNameInput" class="form-label">Введите название нового города</label>
|
||||
<input class="form-control" type="text" id="cityNameInput" name="name" required>
|
||||
@error('text')
|
||||
<div class="text-danger">{{ $message }}</div>
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="submit" class="btn btn-primary">Добавить</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
@endsection
|
||||
@ -11,34 +11,29 @@ class="nav-link d-flex align-items-center gap-2 fs-5 border rounded-4 active"
|
||||
<li class="nav-item text-center m-2"><a
|
||||
class="nav-link d-flex align-items-center gap-2 fs-5 border rounded-4 active"
|
||||
href="#">Объекты</a></li>
|
||||
<li>
|
||||
<h6 class="dropdown-header text-uppercase">Пользователи</h6>
|
||||
</li>
|
||||
<li class="nav-item text-center m-2"><a
|
||||
class="nav-link d-flex align-items-center gap-2 fs-5 border rounded-4 active"
|
||||
href="#">Роли</a></li>
|
||||
<li class="nav-item text-center m-2"><a
|
||||
class="nav-link d-flex align-items-center gap-2 fs-5 border rounded-4 active"
|
||||
href="#">Список</a>
|
||||
href="{{ route('admin.users') }}">Пользователи</a>
|
||||
</li>
|
||||
<li>
|
||||
<h6 class="dropdown-header text-uppercase">Справочники</h6>
|
||||
</li>
|
||||
<li class="nav-item text-center m-2"><a
|
||||
class="nav-link d-flex align-items-center gap-2 fs-5 border rounded-4 active"
|
||||
href="#">Города</a></li>
|
||||
href="{{ route('admin.cities') }}">Города</a></li>
|
||||
<li class="nav-item text-center m-2"><a
|
||||
class="nav-link d-flex align-items-center gap-2 fs-5 border rounded-4 active" href="#">ЖК</a>
|
||||
class="nav-link d-flex align-items-center gap-2 fs-5 border rounded-4 active"
|
||||
href="{{ route('admin.complexes') }}">ЖК</a>
|
||||
</li>
|
||||
<li>
|
||||
<h6 class="dropdown-header text-uppercase">Агентства</h6>
|
||||
</li>
|
||||
<li class="nav-item text-center m-2"><a
|
||||
class="nav-link d-flex align-items-center gap-2 fs-5 border rounded-4 active"
|
||||
href="#">Организации</a></li>
|
||||
href="{{ route('admin.companies') }}">Организации</a></li>
|
||||
<li class="nav-item text-center m-2"><a
|
||||
class="nav-link d-flex align-items-center gap-2 fs-5 border rounded-4 active"
|
||||
href="#">Вознаграждения</a></li>
|
||||
href="{{ route('admin.payments') }}">Вознаграждения</a></li>
|
||||
</ul>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
28
app/Modules/Admin/Views/payments/index.blade.php
Normal file
28
app/Modules/Admin/Views/payments/index.blade.php
Normal file
@ -0,0 +1,28 @@
|
||||
@extends('layouts.admin')
|
||||
@section('content')
|
||||
<h1>Вознаграждения</h1>
|
||||
<div class="fs-5 bg-light p-0 m-0 border border-1 rounded-4 py-3">
|
||||
<table class="table m-0">
|
||||
<thead>
|
||||
<tr scope="col">
|
||||
<th>Компания</th>
|
||||
@foreach ($complexes as $complex)
|
||||
<th>{{ $complex->name }}</th>
|
||||
@endforeach
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class=" ">
|
||||
@foreach ($companies as $company)
|
||||
<tr scope="row">
|
||||
<td class="align-middle">
|
||||
{{ $company->name }}
|
||||
</td>
|
||||
@foreach ($complexes as $complex)
|
||||
<td><a href="#" class="" style="text-decoration-style: dotted;">Наследовать</a></td>
|
||||
@endforeach
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@endsection
|
||||
@ -1,11 +1,9 @@
|
||||
@extends('layouts.admin')
|
||||
@section('content')
|
||||
<form class="d-flex mb-3" method="GET" action="{{ route('company.agents.table') }}">
|
||||
|
||||
|
||||
<div class="ms-auto p-2">
|
||||
<a type="button" class="btn btn-primary py-2 px-3 fs-5" href="{{ route('admin.posts.create') }}">
|
||||
<i class="bi bi-postcard"></i>
|
||||
<i class="bi bi-plus"></i> Добавить новость
|
||||
</a>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@ -2,28 +2,32 @@
|
||||
@if ($posts->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">
|
||||
<div class="fs-5 bg-light p-0 m-0 border border-1 rounded-4 py-3">
|
||||
<table class="table m-0">
|
||||
<thead>
|
||||
<tr scope="col">
|
||||
<th>ID
|
||||
<th>Название
|
||||
<th>Дата создания
|
||||
<th>Дата изменения
|
||||
<th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class=" ">
|
||||
@foreach ($posts as $post)
|
||||
<tr scope="row">
|
||||
<td class="fw-semibold fs-5 align-middle">
|
||||
{{ $post->id }}
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
{{ $post->name }}
|
||||
</td>
|
||||
<td>
|
||||
{{ $post->created_at->diffForHumans() }}
|
||||
</td>
|
||||
<td>
|
||||
@if ($post->created_at != $post->updated_at)
|
||||
{{ $post->updated_at->diffForHumans() }}
|
||||
@else
|
||||
—
|
||||
@endif
|
||||
</td>
|
||||
<td>
|
||||
<div class="dropdown" style="">
|
||||
<button class="btn btn-light" type="button" id="dropdownMenuButton"
|
||||
|
||||
76
app/Modules/Admin/Views/users/edit.blade.php
Normal file
76
app/Modules/Admin/Views/users/edit.blade.php
Normal file
@ -0,0 +1,76 @@
|
||||
@extends('layouts.admin')
|
||||
@section('content')
|
||||
<div class="fs-5 bg-light p-0 m-0 border border-1 rounded-4 p-3">
|
||||
|
||||
<h4 class="fw-bold my-3">Редактировать данные пользователя</h4>
|
||||
<form action="{{ route('admin.users.update', ['user' => $user]) }}" method="post" enctype="multipart/form-data">
|
||||
@csrf
|
||||
<div class="mb-3">
|
||||
<label for="nameFormControl" class="form-label">ФИО</label>
|
||||
<input type="text" class="form-control" id="nameFormControl" name="name" value="{{ $user->name }}">
|
||||
@error('name')
|
||||
<div class="text-danger">{{ $message }}</div>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="mb-3">
|
||||
<label for="emailFormControl" class="form-label">Email</label>
|
||||
<input type="text" class="form-control" id="emailFormControl" name="email"
|
||||
value="{{ $user->email }}">
|
||||
@error('email')
|
||||
<div class="text-danger">{{ $message }}</div>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="phoneFormControl" class="form-label">телефон</label>
|
||||
<input type="text" class="form-control" id="phoneFormControl" name="phone"
|
||||
value="{{ $user->phone }}">
|
||||
@error('phone')
|
||||
<div class="text-danger">{{ $message }}</div>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Сохранить</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="fs-5 bg-light p-0 m-0 border border-1 rounded-4 mt-3 pb-3">
|
||||
<h4 class="fw-bold m-3">Роли пользователя</h4>
|
||||
<table class="table m-0">
|
||||
<thead>
|
||||
<tr scope="col">
|
||||
<th>Роль
|
||||
<th>Когда назначена
|
||||
<th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class=" ">
|
||||
@foreach ($userRoles as $userRole)
|
||||
<tr scope="row">
|
||||
<td class="align-middle">
|
||||
{{ __($userRole->role->name) }}
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
{{ $userRole->created_at->diffForHumans() }}
|
||||
</td>
|
||||
<td class="text-end">
|
||||
<div class="dropdown" style="">
|
||||
<button class="btn btn-light" type="button" id="dropdownMenuButton"
|
||||
data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
<i class="bi bi-three-dots-vertical"></i>
|
||||
</button>
|
||||
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
|
||||
<form method="post"
|
||||
action="{{ route('admin.users.role.delete', ['userRole' => $userRole]) }}">
|
||||
@csrf
|
||||
<button class="dropdown-item" type="submit">Удалить</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@endsection
|
||||
80
app/Modules/Admin/Views/users/index.blade.php
Normal file
80
app/Modules/Admin/Views/users/index.blade.php
Normal file
@ -0,0 +1,80 @@
|
||||
@extends('layouts.admin')
|
||||
@section('content')
|
||||
<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') }}">
|
||||
<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"
|
||||
onclick="this.form.submit()" {{ $role == 'all' || !$role ? 'checked' : '' }}>
|
||||
<label class="btn p-2 fs-5" for="option_all">Все</label>
|
||||
@foreach ($roles as $roleItem)
|
||||
<input type="radio" class="btn-check" name="role" value="{{ $roleItem->id }}"
|
||||
id="option_{{ $roleItem->id }}" autocomplete="off" onclick="this.form.submit()"
|
||||
{{ $roleItem->id == $role ? 'checked' : '' }}>
|
||||
<label class="btn p-2 fs-5" for="option_{{ $roleItem->id }}">{{ __($roleItem->name) }}</label>
|
||||
@endforeach
|
||||
</div>
|
||||
|
||||
<div class="ms-auto p-2">
|
||||
<!--<button type="button" class="btn btn-primary py-2 px-3 fs-5" data-bs-toggle="modal"
|
||||
data-bs-target="#createAgentModal">
|
||||
<i class="bi bi-person-plus"></i>
|
||||
</button>-->
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div class="fs-5 bg-light p-0 m-0 border border-1 rounded-4 py-3">
|
||||
<table class="table m-0">
|
||||
<thead>
|
||||
<tr scope="col">
|
||||
<th>ФИО
|
||||
<th>Email
|
||||
<th>Телефон
|
||||
<th>Создан
|
||||
<th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class=" ">
|
||||
@foreach ($users as $user)
|
||||
<tr scope="row">
|
||||
<td class="align-middle">
|
||||
{{ $user->name }}
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
{{ $user->email }}
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
{{ $user->phone }}
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
{{ $user->created_at->diffForHumans() }}
|
||||
</td>
|
||||
<td>
|
||||
<div class="dropdown" style="">
|
||||
<button class="btn btn-light" type="button" id="dropdownMenuButton"
|
||||
data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
<i class="bi bi-three-dots-vertical"></i>
|
||||
</button>
|
||||
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
|
||||
<a class="dropdown-item"
|
||||
href="{{ route('admin.users.edit', ['user' => $user]) }}">Редактировать</a>
|
||||
<form method="post"
|
||||
action="{{ route('admin.posts.delete', ['post' => $user]) }}">
|
||||
@csrf
|
||||
<button class="dropdown-item" type="submit">Удалить</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@endif
|
||||
@livewire('post.card')
|
||||
</div>
|
||||
|
||||
@endsection
|
||||
@ -0,0 +1,30 @@
|
||||
<?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('cities', function (Blueprint $table)
|
||||
{
|
||||
$table->softDeletes();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('cities', function (Blueprint $table)
|
||||
{
|
||||
//
|
||||
});
|
||||
}
|
||||
};
|
||||
@ -0,0 +1,30 @@
|
||||
<?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('complexes', function (Blueprint $table)
|
||||
{
|
||||
$table->softDeletes();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('complexes', function (Blueprint $table)
|
||||
{
|
||||
//
|
||||
});
|
||||
}
|
||||
};
|
||||
@ -36,5 +36,9 @@
|
||||
"Credits": "Ипотека",
|
||||
"News": "Новости",
|
||||
"Projects": "Проекты",
|
||||
"Sale": "Акции"
|
||||
"Sale": "Акции",
|
||||
"Super admin": "Суперадмин",
|
||||
"Company admin": "Администратор агентства",
|
||||
"Agent": "Агент",
|
||||
"Client": "Клиент"
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user