first commit
This commit is contained in:
55
resources/views/admin/posts/_form.blade.php
Executable file
55
resources/views/admin/posts/_form.blade.php
Executable file
@ -0,0 +1,55 @@
|
||||
<div class="example">
|
||||
<ul class="nav nav-tabs " id="myTab" role="tablist">
|
||||
@foreach($localizations as $localization)
|
||||
<li class="nav-item">
|
||||
<a class="nav-link @if($loop->first) active @endif" id="{{ $localization->name }}-tab" data-bs-toggle="tab" data-bs-target="#{{ $localization->name }}" role="tab" aria-controls="{{ $localization->name }}" aria-selected="true">
|
||||
{{ strtoupper($localization->name) }}
|
||||
</a>
|
||||
</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
<div class="tab-content border border-top-0 p-3" id="myTabContent">
|
||||
@foreach ($localizations as $locale)
|
||||
<div class="tab-pane fade @if($loop->first) show active @endif" id="{{ $locale->name }}" role="tabpanel" aria-labelledby="{{$locale->name}}-tab">
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Заголовок</label>
|
||||
<input type="text" name="translations[{{ $locale->id }}][title]" class="form-control @error('translations.*') is-invalid @enderror " @isset($post) value="{{ $post->getTranslatedAttributes($locale->id)->title }}" @endisset placeholder="Введите заголовок...">
|
||||
@error('translations.*.title')
|
||||
<span class="invalid-feedback" role="alert">{{ $message }}</span>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Описание</label>
|
||||
<input type="text" name="translations[{{ $locale->id }}][description]" class="form-control" @isset($post) value="{{ $post->getTranslatedAttributes($locale->id)->description }}" @endisset placeholder="Введите описание...">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Контент</label>
|
||||
<textarea class="form-control ckeditor" name="translations[{{ $locale->id }}][body]" rows="10">@isset($post) {{ $post->getTranslatedAttributes($locale->id)->body }} @endisset</textarea>
|
||||
</div>
|
||||
@isset($post)
|
||||
<input type="hidden" name="translations[{{ $locale->id }}][id]" value="{{ $post->getTranslatedAttributes($locale->id)->id }}">
|
||||
@endisset
|
||||
</div>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="image" class="form-label">Фото</label>
|
||||
<input type="file" name="image" id="image" class="form-control" value="{{ $post->image ?? '' }}">
|
||||
</div>
|
||||
|
||||
<div class="d-flex justify-content-between">
|
||||
<button type="submit" class="btn btn-primary me-2">
|
||||
@isset($post) Обновить @else Сохранить @endisset
|
||||
</button>
|
||||
</div>
|
||||
|
||||
|
||||
@push('plugin-scripts')
|
||||
<script src="{{ asset('assets/plugins/tinymce/tinymce.min.js') }}"></script>
|
||||
@endpush
|
||||
|
||||
@push('custom-scripts')
|
||||
<script src="{{ asset('assets/js/tinymce.js') }}"></script>
|
||||
@endpush
|
29
resources/views/admin/posts/create.blade.php
Executable file
29
resources/views/admin/posts/create.blade.php
Executable file
@ -0,0 +1,29 @@
|
||||
@extends('layout.master')
|
||||
|
||||
@section('content')
|
||||
@include('admin.partials.breadcrumb', ['subPage'=>'Создать', 'page'=>'Новости', 'pageUrl'=>route('admin.posts.index')])
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h6 class="card-title">Создание новости</h6>
|
||||
<form action="{{ route('admin.posts.store') }}" method="POST" enctype="multipart/form-data" class="forms-sample">
|
||||
@csrf
|
||||
@include('admin.posts._form')
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@push('custom-scripts')
|
||||
<script src="{{ asset('assets/plugins/ckeditor/ckeditor.js') }}"></script>
|
||||
<script>
|
||||
CKEDITOR.replace('body', {
|
||||
filebrowserUploadUrl: "{{ route('admin.post.storeImage', ['_token' => csrf_token() ]) }}",
|
||||
filebrowserUploadMethod: 'form'
|
||||
});
|
||||
</script>
|
||||
@endpush
|
30
resources/views/admin/posts/edit.blade.php
Executable file
30
resources/views/admin/posts/edit.blade.php
Executable file
@ -0,0 +1,30 @@
|
||||
@extends('layout.master')
|
||||
|
||||
@section('content')
|
||||
@include('admin.partials.breadcrumb', ['subPage'=>'Изменить', 'page'=>'Новости', 'pageUrl'=>route('admin.posts.index')])
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h6 class="card-title">Изменения новости</h6>
|
||||
<form action="{{ route('admin.posts.update', $post->id) }}" method="POST" enctype="multipart/form-data" class="forms-sample">
|
||||
@csrf
|
||||
@method('PUT')
|
||||
@include('admin.posts._form')
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@push('custom-scripts')
|
||||
<script src="{{ asset('assets/plugins/ckeditor/ckeditor.js') }}"></script>
|
||||
<script>
|
||||
CKEDITOR.replace('body', {
|
||||
filebrowserUploadUrl: "{{ route('admin.post.storeImage', ['_token' => csrf_token() ]) }}",
|
||||
filebrowserUploadMethod: 'form'
|
||||
});
|
||||
</script>
|
||||
@endpush
|
70
resources/views/admin/posts/index.blade.php
Executable file
70
resources/views/admin/posts/index.blade.php
Executable file
@ -0,0 +1,70 @@
|
||||
@extends('layout.master')
|
||||
|
||||
@push('plugin-styles')
|
||||
<link href="{{ asset('assets/plugins/datatables-net-bs5/dataTables.bootstrap5.css') }}" rel="stylesheet"/>
|
||||
@endpush
|
||||
|
||||
@section('content')
|
||||
|
||||
@include('admin.partials.breadcrumb', ['page'=>'Новости'])
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12 grid-margin stretch-card">
|
||||
<div class="card">
|
||||
<div class="card-header d-flex justify-content-between">
|
||||
<h6 class="card-title">Новости</h6>
|
||||
<a href="{{ route('admin.posts.create') }}" class="btn btn-primary">Создать</a>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="table-responsive">
|
||||
<table id="dataTableExample" class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>T/R</th>
|
||||
<th>Заголовок</th>
|
||||
<th>Фото</th>
|
||||
<th>Дата создания</th>
|
||||
<th>Действия</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($posts as $post)
|
||||
<tr>
|
||||
<td>{{ $loop->iteration }}</td>
|
||||
<td>
|
||||
{{ $post->getTranslatedAttributes(session('locale_id'))->title ?? 'no title' }}
|
||||
</td>
|
||||
<td><img src="{{ post_file_path().$post->image }}" alt="" width="200"></td>
|
||||
<td>{{ $post->created_at->format('d.m.Y / H:i') }}</td>
|
||||
<td class="d-flex align-items-center">
|
||||
<a href="{{ route('admin.posts.show', $post->id) }}" class="btn btn-primary" style="margin-right: 10px;">
|
||||
Посмотреть
|
||||
</a>
|
||||
<a href="{{ route('admin.posts.edit', $post->id) }}" class="btn btn-success" style="margin-right: 10px;">
|
||||
Редактировать
|
||||
</a>
|
||||
<form action="{{ route('admin.posts.destroy', $post->id) }}" method="POST">
|
||||
@csrf
|
||||
@method('DELETE')
|
||||
<button type="submit" class="btn btn-danger">Удалить</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@push('plugin-scripts')
|
||||
<script src="{{ asset('assets/plugins/datatables-net/jquery.dataTables.js') }}"></script>
|
||||
<script src="{{ asset('assets/plugins/datatables-net-bs5/dataTables.bootstrap5.js') }}"></script>
|
||||
@endpush
|
||||
|
||||
@push('custom-scripts')
|
||||
<script src="{{ asset('assets/js/data-table.js') }}"></script>
|
||||
@endpush
|
49
resources/views/admin/posts/show.blade.php
Executable file
49
resources/views/admin/posts/show.blade.php
Executable file
@ -0,0 +1,49 @@
|
||||
@extends('layout.master')
|
||||
|
||||
@section('content')
|
||||
@include('admin.partials.breadcrumb', ['subPage'=>'Посмотреть', 'page'=>'Новости', 'pageUrl'=>route('admin.posts.index')])
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h6 class="card-title">Новость ID: {{ $post->id }}</h6>
|
||||
<div class="example">
|
||||
<ul class="nav nav-tabs" id="myTab" role="tablist">
|
||||
@foreach($localizations as $localization)
|
||||
<li class="nav-item">
|
||||
<a class="nav-link @if($loop->first) active @endif" id="{{ $localization->name }}-tab" data-bs-toggle="tab" data-bs-target="#{{ $localization->name }}" role="tab" aria-controls="{{ $localization->name }}" aria-selected="true">{{ strtoupper($localization->name) }}</a>
|
||||
</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
|
||||
<div class="tab-content border border-top-0 p-3" id="myTabContent">
|
||||
@foreach ($localizations as $locale)
|
||||
<div class="tab-pane fade @if($loop->first) show active @endif" id="{{ $locale->name }}" role="tabpanel" aria-labelledby="{{ $locale->name }}-tab">
|
||||
<h6 class="mb-1">Заголовок</h6>
|
||||
<p>{{ $post->getTranslatedAttributes($locale->id)->title }}</p>
|
||||
<hr>
|
||||
<h6 class="mb-1">Описание</h6>
|
||||
<p>{{ $post->getTranslatedAttributes($locale->id)->description }}</p>
|
||||
<hr>
|
||||
<h6 class="mb-1">Контент</h6>
|
||||
<p>{!! $post->getTranslatedAttributes($locale->id)->body !!}</p>
|
||||
</div>
|
||||
@endforeach
|
||||
</div>
|
||||
<hr>
|
||||
<div>
|
||||
<h6 class="mb-1">Фото</h6>
|
||||
<img src="{{ post_file_path().$post->image }}" alt="" width="400">
|
||||
</div>
|
||||
<hr>
|
||||
<div>
|
||||
<h6 class="mb-1">Slug</h6>
|
||||
<p>{{ $post->slug }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
Reference in New Issue
Block a user