admin design module
This commit is contained in:
parent
5e406f9424
commit
ca7d2fa96c
@ -0,0 +1,29 @@
|
||||
<?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::create('design', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('parameter');
|
||||
$table->string('value');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('design');
|
||||
}
|
||||
};
|
||||
47
app/Modules/Admin/Http/Controllers/AdminDesignController.php
Normal file
47
app/Modules/Admin/Http/Controllers/AdminDesignController.php
Normal file
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Admin\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
use Modules\Main\Models\Design;
|
||||
|
||||
class AdminDesignController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
return view('admin::design.index', [
|
||||
'parameters' => Design::getParameters()
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(Request $request)
|
||||
{
|
||||
|
||||
$validated = $request->validate([
|
||||
'logo' => 'mimes:jpeg,png,jpg,gif,svg'
|
||||
]);
|
||||
|
||||
if ($request->file('logo')) {
|
||||
$logoPath = $request->file('logo')->store('design', ['disk' => 'public']);
|
||||
$request->logo = $logoPath;
|
||||
}
|
||||
|
||||
foreach (Design::parameters as $parameter) {
|
||||
if ( !isset($request->$parameter) || !$request->$parameter ) {
|
||||
if ($parameter != 'logo') {
|
||||
Design::where('parameter', $parameter)->delete();
|
||||
}
|
||||
} else {
|
||||
Design::updateOrCreate([
|
||||
'parameter' => $parameter,
|
||||
'value' => $request->$parameter
|
||||
]);
|
||||
}
|
||||
}
|
||||
return to_route('admin.design');
|
||||
}
|
||||
|
||||
}
|
||||
@ -9,6 +9,8 @@
|
||||
{
|
||||
Route::middleware(['auth', AdminPolicyAuthorization::class])->group(function ()
|
||||
{
|
||||
Route::get('/admin/design', [Modules\Admin\Http\Controllers\AdminDesignController::class, 'index'])->name('admin.design');
|
||||
Route::post('/admin/design/update', [Modules\Admin\Http\Controllers\AdminDesignController::class, 'update'])->name('admin.design.update');
|
||||
|
||||
Route::post('/admin/cities/{city}/update', [Modules\Admin\Http\Controllers\AdminCitiesController::class, 'update'])->name('admin.cities.update');
|
||||
Route::post('/admin/cities/create', [Modules\Admin\Http\Controllers\AdminCitiesController::class, 'create'])->name('admin.cities.create');
|
||||
|
||||
74
app/Modules/Admin/Views/design/index.blade.php
Normal file
74
app/Modules/Admin/Views/design/index.blade.php
Normal file
@ -0,0 +1,74 @@
|
||||
@php($title = 'Настройки темы')
|
||||
@extends('layouts.admin')
|
||||
@section('content')
|
||||
<form method="post" action="{{ route('admin.design.update') }}" enctype="multipart/form-data">
|
||||
@csrf
|
||||
<h5 class="mt-3">Основное</h5>
|
||||
<div class="d-flex gap-3">
|
||||
<div class="col d-flex flex-row justify-content-start align-items-center gap-2 bg-light rounded p-2">
|
||||
<label for="page_color" class="form-label m-0">Цвет страницы</label>
|
||||
<input type="color" class="form-control form-control-color" id="page_color" name="page_color"
|
||||
value="{{ ($parameters['page_color'] ?? '') }}">
|
||||
</div>
|
||||
<div class="col d-flex flex-row justify-content-start align-items-center gap-2 bg-light rounded p-2">
|
||||
<label for="text_color" class="form-label m-0">Цвет основного текста</label>
|
||||
<input type="color" class="form-control form-control-color" id="text_color" name="text_color"
|
||||
value="{{ ($parameters['text_color'] ?? '') }}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col mt-3 d-flex flex-row justify-content-start align-items-center gap-2 bg-light rounded p-2">
|
||||
<label for="logo" class="form-label m-0">Логотип</label>
|
||||
@if(array_key_exists('logo', $parameters))
|
||||
<a href="{{ url('/storage/' . $parameters['logo']) }}" class="w-50 text-truncate">{{ $parameters['logo'] }}</a>
|
||||
@endif
|
||||
<input class="form-control" type="file" name="logo" id="logo">
|
||||
<!--<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox" name="deleteLogo" id="deleteLogoCheck">
|
||||
<label class="form-check-label" for="deleteLogoCheck">
|
||||
Удалить
|
||||
</label>
|
||||
</div>-->
|
||||
</div>
|
||||
<h5 class="mt-3">Акценты</h5>
|
||||
<div class="d-flex gap-3">
|
||||
<div class="col d-flex flex-row justify-content-start align-items-center gap-2 bg-light rounded p-2">
|
||||
<label for="primary_color" class="form-label m-0">Акцент 1</label>
|
||||
<input type="color" class="form-control form-control-color" id="primary_color" name="primary_color"
|
||||
value="{{ ($parameters['primary_color'] ?? '') }}">
|
||||
</div>
|
||||
|
||||
<div class="col d-flex flex-row justify-content-start align-items-center gap-2 bg-light rounded p-2">
|
||||
<label for="secondary_color" class="form-label m-0">Акцент 2</label>
|
||||
<input type="color" class="form-control form-control-color" id="secondary_color" name="secondary_color"
|
||||
value="{{ ($parameters['secondary_color'] ?? '') }}">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h5 class="mt-3">Главное меню</h5>
|
||||
<div class="d-flex gap-3">
|
||||
<div class="col d-flex flex-row justify-content-start align-items-center gap-2 bg-light rounded p-2">
|
||||
<label for="menu_btn_color" class="form-label m-0">Цвет кнопки меню</label>
|
||||
<input type="color" class="form-control form-control-color" id="menu_btn_color" name="menu_btn_color"
|
||||
value="{{ ($parameters['menu_btn_color'] ?? '') }}">
|
||||
</div>
|
||||
|
||||
<div class="col d-flex flex-row justify-content-start align-items-center gap-2 bg-light rounded p-2">
|
||||
<label for="menu_btn_hover_color" class="form-label m-0">Цвет кнопки меню при наведении</label>
|
||||
<input type="color" class="form-control form-control-color" id="menu_btn_hover_color"
|
||||
name="menu_btn_hover_color" value="{{ ($parameters['menu_btn_hover_color'] ?? '') }}">
|
||||
</div>
|
||||
|
||||
<div class="col d-flex flex-row justify-content-start align-items-center gap-2 bg-light rounded p-2">
|
||||
<label for="menu_btn_text_color" class="form-label m-0">Цвет текста кнопки меню</label>
|
||||
<input type="color" class="form-control form-control-color" id="menu_btn_text_color"
|
||||
name="menu_btn_text_color" value="{{ ($parameters['menu_btn_text_color'] ?? '') }}">
|
||||
</div>
|
||||
<div class="col d-flex flex-row justify-content-start align-items-center gap-2 bg-light rounded p-2">
|
||||
<label for="menu_btn_hover_text_color" class="form-label m-0">Цвет текста кнопки меню при наведении</label>
|
||||
<input type="color" class="form-control form-control-color" id="menu_btn_hover_text_color"
|
||||
name="menu_btn_hover_text_color" value="{{ ($parameters['menu_btn_hover_text_color'] ?? '') }}">
|
||||
</div>
|
||||
</div>
|
||||
<input type="submit" class="btn btn-primary mt-3" value="Сохранить" />
|
||||
</form>
|
||||
@endsection
|
||||
@ -2,7 +2,6 @@
|
||||
@extends('layouts.admin')
|
||||
@section('content')
|
||||
<form action="{{ route('admin.docs.update', ['document' => $document]) }}" method="post" enctype="multipart/form-data">
|
||||
@csrf
|
||||
@csrf
|
||||
<div class="my-3">
|
||||
<label for="nameInput" class="form-label">Название файла</label>
|
||||
|
||||
@ -11,6 +11,9 @@ class="nav-link d-flex align-items-center gap-2 fs-5 border rounded-4" href="#">
|
||||
<li class="nav-item text-center m-2"><a class="nav-link d-flex align-items-center gap-2 fs-5 border rounded-4"
|
||||
href="{{ route('admin.users') }}">Пользователи</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"
|
||||
href="{{ route('admin.design') }}">Оформление</a>
|
||||
</li>
|
||||
<li>
|
||||
<h6 class="dropdown-header text-uppercase">Справочники</h6>
|
||||
</li>
|
||||
|
||||
42
app/Modules/Main/Models/Design.php
Normal file
42
app/Modules/Main/Models/Design.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Main\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Design extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
protected $table = 'design';
|
||||
protected $fillable = [
|
||||
'parameter',
|
||||
'value',
|
||||
];
|
||||
|
||||
public const parameters = [
|
||||
'logo',
|
||||
'page_color',
|
||||
'text_color',
|
||||
'primary_color',
|
||||
'secondary_color',
|
||||
'menu_btn_color',
|
||||
'menu_btn_hover_color',
|
||||
'menu_btn_text_color',
|
||||
'menu_btn_hover_text_color'
|
||||
];
|
||||
|
||||
public static function getParameters() {
|
||||
$parameters = [];
|
||||
foreach (Design::all() as $row) {
|
||||
$parameters[$row->parameter] = $row->value;
|
||||
}
|
||||
foreach (self::parameters as $parameter) {
|
||||
if (!array_key_exists($parameter, $parameters)) {
|
||||
$parameters[$parameter] = null;
|
||||
}
|
||||
}
|
||||
return $parameters;
|
||||
}
|
||||
|
||||
}
|
||||
@ -24,8 +24,8 @@
|
||||
|
||||
if($json['total_commits'] > 0)
|
||||
{
|
||||
//$result = shell_exec("cd /var/www/lk && git reset --hard HEAD && git pull && php artisan migrate");
|
||||
$result = shell_exec("cd /var/www/lk && git reset --hard HEAD && git pull");
|
||||
$result = shell_exec("cd /var/www/lk && git reset --hard HEAD && git pull && php artisan migrate && npm run build");
|
||||
//$result = shell_exec("cd /var/www/lk && git reset --hard HEAD && git pull");
|
||||
echo "<p>$result</p>";
|
||||
}
|
||||
|
||||
|
||||
@ -1,3 +1,7 @@
|
||||
.btn:hover{
|
||||
color:#fff;
|
||||
filter: drop-shadow(2px 4px 6px black);
|
||||
}
|
||||
.bg-primary {
|
||||
background-color: #e6662a !important;
|
||||
background-image: linear-gradient(140deg, hsl(19, 79%, 53%) 50%, #ce4711 75%) !important;
|
||||
|
||||
@ -16,6 +16,7 @@
|
||||
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
|
||||
@vite(['resources/sass/app.scss', 'resources/js/app.js', 'resources/css/app.css', 'resources/css/docs.css'])
|
||||
@include('layouts.design')
|
||||
</head>
|
||||
|
||||
<body>
|
||||
@ -24,7 +25,11 @@
|
||||
<div class="container">
|
||||
<div class="col-auto col-sm-2 text-center">
|
||||
<a class="navbar-brand">
|
||||
<img src={{ url('/images/logo.png') }} alt="Logo" width="70">
|
||||
@if(DESIGN_PARAMETERS['logo'])
|
||||
<img src="{{ url('/storage/' . DESIGN_PARAMETERS['logo']) }}" alt="Logo" height="70">
|
||||
@else
|
||||
<img src={{ url('/images/logo.png') }} alt="Logo" width="70">
|
||||
@endif
|
||||
</a>
|
||||
</div>
|
||||
<div class="col px-0 px-md-4 text-start align-middle" id="pageTitle">
|
||||
|
||||
@ -17,6 +17,7 @@
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
|
||||
<script src="https://plan7.ru/catalog/exp/cat.js"></script>
|
||||
@vite(['resources/sass/app.scss', 'resources/js/app.js', 'resources/js/multiselect.js', 'resources/css/app.css', 'resources/css/docs.css', 'resources/css/multiselect.css'])
|
||||
@include('layouts.design')
|
||||
</head>
|
||||
|
||||
<body>
|
||||
@ -49,12 +50,12 @@
|
||||
<img src="../../images/icons/user.png" class="img-fluid align-middle" style="height: 40px;">
|
||||
</a>
|
||||
|
||||
<div class="dropdown-menu dropdown-menu-end" aria-labelledby="navbarDropdown" style="z-index:1040;">
|
||||
<div class="dropdown-menu dropdown-menu-end" aria-labelledby="navbarDropdown"
|
||||
style="z-index:1040;">
|
||||
<a class="dropdown-item" href="/profile">
|
||||
Профиль
|
||||
</a>
|
||||
<a class="dropdown-item" href="{{ route('logout') }}"
|
||||
onclick="event.preventDefault();
|
||||
<a class="dropdown-item" href="{{ route('logout') }}" onclick="event.preventDefault();
|
||||
document.getElementById('logout-form').submit();">
|
||||
Выйти
|
||||
</a>
|
||||
@ -92,7 +93,8 @@
|
||||
<label for="floatingSelect">Выберите тему обращения</label>
|
||||
</div>
|
||||
<div class="form-floating mt-3">
|
||||
<textarea rows="4" class="form-control" placeholder="Оставьте текст обращения в этом поле" id="floatingTextarea"></textarea>
|
||||
<textarea rows="4" class="form-control" placeholder="Оставьте текст обращения в этом поле"
|
||||
id="floatingTextarea"></textarea>
|
||||
<label for="floatingTextarea">Текст обращения</label>
|
||||
</div>
|
||||
</div>
|
||||
@ -154,4 +156,4 @@
|
||||
@include('notice::index')
|
||||
</body>
|
||||
|
||||
</html>
|
||||
</html>
|
||||
114
resources/views/layouts/design.blade.php
Normal file
114
resources/views/layouts/design.blade.php
Normal file
@ -0,0 +1,114 @@
|
||||
<?
|
||||
use Modules\Main\Models\Design;
|
||||
define('DESIGN_PARAMETERS', Design::getParameters());
|
||||
|
||||
?>
|
||||
<style>
|
||||
@if(DESIGN_PARAMETERS['page_color'])
|
||||
#app, html {
|
||||
background-color: {{ DESIGN_PARAMETERS['page_color'] }};
|
||||
}
|
||||
@endif
|
||||
|
||||
@if(DESIGN_PARAMETERS['text_color'] && 1==2)
|
||||
#app *{
|
||||
color: {{ DESIGN_PARAMETERS['text_color'] }};
|
||||
}
|
||||
@endif
|
||||
|
||||
@if(DESIGN_PARAMETERS['primary_color'])
|
||||
.form-control:focus, .form-select:focus {
|
||||
border-color: {{ DESIGN_PARAMETERS['primary_color'] }}60;
|
||||
box-shadow: 0 0 0 .25rem {{ DESIGN_PARAMETERS['primary_color'] }}40;
|
||||
}
|
||||
.text-primary, a:not(.nav-link, .mobile_menu_item, .btn ) {
|
||||
color: {{ DESIGN_PARAMETERS['primary_color'] }}!important;
|
||||
}
|
||||
|
||||
.bg-primary {
|
||||
background-color:
|
||||
{{ DESIGN_PARAMETERS['primary_color'] }}
|
||||
!important;
|
||||
background-image: linear-gradient(140deg,
|
||||
{{ DESIGN_PARAMETERS['primary_color'] }}
|
||||
50%,
|
||||
{{ DESIGN_PARAMETERS['primary_color'] }}
|
||||
75%) !important;
|
||||
border-color:
|
||||
{{ DESIGN_PARAMETERS['primary_color'] }}
|
||||
!important;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background-color:
|
||||
{{ DESIGN_PARAMETERS['primary_color'] }}
|
||||
!important;
|
||||
border-color:
|
||||
{{ DESIGN_PARAMETERS['primary_color'] }}
|
||||
!important;
|
||||
}
|
||||
|
||||
input[type="radio"]:checked+label {
|
||||
background-color: {{ DESIGN_PARAMETERS['primary_color'] }} !important;
|
||||
border-color: {{ DESIGN_PARAMETERS['primary_color'] }} !important;
|
||||
}
|
||||
|
||||
.form-check-input:checked
|
||||
{
|
||||
background-color: {{ DESIGN_PARAMETERS['primary_color'] }};
|
||||
border-color: {{ DESIGN_PARAMETERS['primary_color'] }};
|
||||
}
|
||||
@endif
|
||||
|
||||
@if(DESIGN_PARAMETERS['secondary_color'])
|
||||
.btn-secondary,
|
||||
.btn-secondary:disabled {
|
||||
background-color:
|
||||
{{ DESIGN_PARAMETERS['secondary_color'] }}
|
||||
!important;
|
||||
border-color:
|
||||
{{ DESIGN_PARAMETERS['secondary_color'] }}
|
||||
!important;
|
||||
}
|
||||
@endif
|
||||
|
||||
@if(DESIGN_PARAMETERS['menu_btn_color'])
|
||||
#leftPanel .nav-link {
|
||||
background-color: {{ DESIGN_PARAMETERS['menu_btn_color'] }};
|
||||
}
|
||||
@endif
|
||||
|
||||
@if(DESIGN_PARAMETERS['menu_btn_hover_color'])
|
||||
#leftPanel .nav-link:hover {
|
||||
background-color: {{ DESIGN_PARAMETERS['menu_btn_hover_color'] }};
|
||||
}
|
||||
#leftPanel .nav-link.active {
|
||||
background-color: {{ DESIGN_PARAMETERS['menu_btn_hover_color'] }};
|
||||
}
|
||||
@endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*pagination*/
|
||||
.page-item>.page-link,
|
||||
.page-item:first-child .page-link,
|
||||
.page-item:last-child .page-link {
|
||||
color: #ccc;
|
||||
border-color: #ccc;
|
||||
border-radius: 12px;
|
||||
margin: 0 6px 0px 6px !important;
|
||||
padding-top: 8px;
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
|
||||
.active>.page-link {
|
||||
background-color: #ffffff !important;
|
||||
color: rgb(44, 44, 44) !important;
|
||||
border-color: #b6b6b6 !important;
|
||||
}
|
||||
</style>
|
||||
@ -21,6 +21,7 @@
|
||||
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
|
||||
@vite(['resources/sass/app.scss', 'resources/js/app.js', 'resources/css/app.css'])
|
||||
@include('layouts.design')
|
||||
<style>
|
||||
html,
|
||||
body {
|
||||
|
||||
@ -103,7 +103,7 @@ class="d-none d-lg-inline text-truncate">{{ $item['name'] }}</span>
|
||||
<div>
|
||||
@if ($item['target'] == 'route')
|
||||
<a href="{{ route($item['route']) }}"
|
||||
class="d-flex flex-column align-items-center text-white text-decoration-none
|
||||
class="d-flex flex-column mobile_menu_item align-items-center text-white text-decoration-none
|
||||
@if (Route::currentRouteName() == $item['route']) text-decoration-underline @endif"
|
||||
aria-current="page">
|
||||
<i class="bi bi-{{ $item['icon'] }}"></i>
|
||||
@ -112,7 +112,7 @@ class="d-flex flex-column align-items-center text-white text-decoration-none
|
||||
@endif
|
||||
@if ($item['target'] == 'modal')
|
||||
<a href="#" data-bs-toggle="modal" data-bs-target="{{ $item['modal'] }}"
|
||||
class="d-flex flex-column align-items-center text-white text-decoration-none"
|
||||
class="d-flex flex-column mobile_menu_item align-items-center text-white text-decoration-none"
|
||||
aria-current="page">
|
||||
<i class="bi bi-{{ $item['icon'] }}"></i>
|
||||
<span style="margin-top:-10px" class=" text-truncate fs-6">{{ $item['name'] }}</span>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user