This commit is contained in:
71
resources/views/admin/home-slides/_form.blade.php
Normal file
71
resources/views/admin/home-slides/_form.blade.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<label>
|
||||
Блок на главной
|
||||
<select name="zone" required>
|
||||
@foreach ($zoneLabels as $zoneKey => $zoneLabel)
|
||||
<option value="{{ $zoneKey }}" @selected(old('zone', $slide->zone ?? 'left') === $zoneKey)>{{ $zoneLabel }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
Заголовок
|
||||
<input type="text" name="title" value="{{ old('title', $slide->title ?? '') }}" maxlength="160" placeholder="Например: Скидки на видеокарты">
|
||||
</label>
|
||||
|
||||
<label>
|
||||
Подзаголовок
|
||||
<textarea name="subtitle" rows="3" maxlength="1500" placeholder="Короткий текст на баннере">{{ old('subtitle', $slide->subtitle ?? '') }}</textarea>
|
||||
</label>
|
||||
|
||||
<div class="pc-grid pc-grid-2">
|
||||
<label>
|
||||
Текст кнопки
|
||||
<input type="text" name="button_text" value="{{ old('button_text', $slide->button_text ?? '') }}" maxlength="60" placeholder="Подробнее">
|
||||
</label>
|
||||
|
||||
<label>
|
||||
Ссылка кнопки
|
||||
<input type="text" name="button_url" value="{{ old('button_url', $slide->button_url ?? '') }}" maxlength="255" placeholder="/catalog или https://...">
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="pc-grid pc-grid-3">
|
||||
<label class="pc-checkbox">
|
||||
<input type="checkbox" name="show_title" value="1" @checked(old('show_title', $slide->show_title ?? true))>
|
||||
<span>Показывать заголовок</span>
|
||||
</label>
|
||||
<label class="pc-checkbox">
|
||||
<input type="checkbox" name="show_subtitle" value="1" @checked(old('show_subtitle', $slide->show_subtitle ?? true))>
|
||||
<span>Показывать описание</span>
|
||||
</label>
|
||||
<label class="pc-checkbox">
|
||||
<input type="checkbox" name="show_button" value="1" @checked(old('show_button', $slide->show_button ?? true))>
|
||||
<span>Показывать кнопку</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="pc-grid pc-grid-2">
|
||||
<label>
|
||||
Порядок
|
||||
<input type="number" min="0" max="9999" name="sort_order" value="{{ old('sort_order', $slide->sort_order ?? 100) }}" required>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
Изображение (jpg, png, webp)
|
||||
<input class="pc-file-input" type="file" name="image" accept=".jpg,.jpeg,.png,.webp,image/jpeg,image/png,image/webp" @required(empty($slide?->id))>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
@if (!empty($slide?->image_url))
|
||||
<div class="pc-admin-slide-current">
|
||||
<div class="pc-admin-slide-current-preview" style="background-image: url('{{ $slide->image_url }}')"></div>
|
||||
<span class="pc-muted">Текущее изображение. Загрузите новое, если хотите заменить.</span>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<label class="pc-checkbox">
|
||||
<input type="checkbox" name="is_active" value="1" @checked(old('is_active', $slide->is_active ?? true))>
|
||||
<span>Слайд активен</span>
|
||||
</label>
|
||||
|
||||
<button class="pc-btn primary" type="submit">{{ $submitLabel ?? 'Сохранить' }}</button>
|
||||
22
resources/views/admin/home-slides/create.blade.php
Normal file
22
resources/views/admin/home-slides/create.blade.php
Normal file
@@ -0,0 +1,22 @@
|
||||
@extends('layouts.shop')
|
||||
|
||||
@section('content')
|
||||
@include('partials.breadcrumbs', [
|
||||
'items' => [
|
||||
['label' => 'Админка', 'url' => route('admin.dashboard')],
|
||||
['label' => 'Слайдеры главной', 'url' => route('admin.home-slides.index')],
|
||||
['label' => 'Новый слайд', 'url' => null],
|
||||
],
|
||||
])
|
||||
|
||||
<section class="pc-section">
|
||||
<div class="pc-section-title">
|
||||
<h2>Новый слайд</h2>
|
||||
</div>
|
||||
|
||||
<form class="pc-card pc-form" method="post" action="{{ route('admin.home-slides.store') }}" enctype="multipart/form-data">
|
||||
@csrf
|
||||
@include('admin.home-slides._form', ['submitLabel' => 'Создать'])
|
||||
</form>
|
||||
</section>
|
||||
@endsection
|
||||
23
resources/views/admin/home-slides/edit.blade.php
Normal file
23
resources/views/admin/home-slides/edit.blade.php
Normal file
@@ -0,0 +1,23 @@
|
||||
@extends('layouts.shop')
|
||||
|
||||
@section('content')
|
||||
@include('partials.breadcrumbs', [
|
||||
'items' => [
|
||||
['label' => 'Админка', 'url' => route('admin.dashboard')],
|
||||
['label' => 'Слайдеры главной', 'url' => route('admin.home-slides.index')],
|
||||
['label' => 'Редактирование', 'url' => null],
|
||||
],
|
||||
])
|
||||
|
||||
<section class="pc-section">
|
||||
<div class="pc-section-title">
|
||||
<h2>Редактирование слайда</h2>
|
||||
</div>
|
||||
|
||||
<form class="pc-card pc-form" method="post" action="{{ route('admin.home-slides.update', $slide) }}" enctype="multipart/form-data">
|
||||
@csrf
|
||||
@method('put')
|
||||
@include('admin.home-slides._form', ['slide' => $slide, 'submitLabel' => 'Сохранить'])
|
||||
</form>
|
||||
</section>
|
||||
@endsection
|
||||
57
resources/views/admin/home-slides/index.blade.php
Normal file
57
resources/views/admin/home-slides/index.blade.php
Normal file
@@ -0,0 +1,57 @@
|
||||
@extends('layouts.shop')
|
||||
|
||||
@section('content')
|
||||
@include('partials.breadcrumbs', [
|
||||
'items' => [
|
||||
['label' => 'Админка', 'url' => route('admin.dashboard')],
|
||||
['label' => 'Слайдеры главной', 'url' => null],
|
||||
],
|
||||
])
|
||||
|
||||
<section class="pc-section">
|
||||
<div class="pc-category-toolbar">
|
||||
<div class="pc-section-title">
|
||||
<h2>Слайдеры главной страницы</h2>
|
||||
<p>Загружайте баннеры для блока 2/3 и 1/3 на первом экране.</p>
|
||||
</div>
|
||||
<div class="pc-product-actions">
|
||||
<a class="pc-btn primary" href="{{ route('admin.home-slides.create', ['zone' => 'left']) }}">Добавить в 2/3</a>
|
||||
<a class="pc-btn ghost" href="{{ route('admin.home-slides.create', ['zone' => 'right']) }}">Добавить в 1/3</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="pc-grid pc-grid-2">
|
||||
@foreach ($zoneLabels as $zone => $zoneLabel)
|
||||
@php
|
||||
$zoneSlides = $slides->get($zone, collect());
|
||||
@endphp
|
||||
<div class="pc-card">
|
||||
<h3>{{ $zoneLabel }}</h3>
|
||||
@if ($zoneSlides->isEmpty())
|
||||
<p>Слайды пока не добавлены.</p>
|
||||
@else
|
||||
<div class="pc-account-orders">
|
||||
@foreach ($zoneSlides as $slide)
|
||||
<div class="pc-admin-slide-item">
|
||||
<div class="pc-admin-slide-preview" style="background-image: url('{{ $slide->image_url }}')"></div>
|
||||
<div class="pc-admin-slide-main">
|
||||
<strong>{{ $slide->title ?: 'Без заголовка' }}</strong>
|
||||
<span class="pc-muted">Порядок: {{ $slide->sort_order }} · {{ $slide->is_active ? 'Активен' : 'Скрыт' }}</span>
|
||||
</div>
|
||||
<div class="pc-product-actions">
|
||||
<a class="pc-btn ghost" href="{{ route('admin.home-slides.edit', $slide) }}">Редактировать</a>
|
||||
<form method="post" action="{{ route('admin.home-slides.destroy', $slide) }}">
|
||||
@csrf
|
||||
@method('delete')
|
||||
<button class="pc-btn ghost" type="submit">Удалить</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
@endforeach
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
@endforeach
|
||||
</div>
|
||||
</section>
|
||||
@endsection
|
||||
Reference in New Issue
Block a user