Resolved conflicts on crud-stamps
This commit is contained in:
commit
3ceaceacb6
21 changed files with 814 additions and 11 deletions
167
app/Http/Controllers/Bo/CommitmentController.php
Normal file
167
app/Http/Controllers/Bo/CommitmentController.php
Normal file
|
|
@ -0,0 +1,167 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Bo;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Bo\Commitments\StoreCommitmentRequest;
|
||||
use App\Http\Requests\Bo\Commitments\UpdateCommitmentRequest;
|
||||
use App\Models\Commitment;
|
||||
use App\Traits\Controllers\ChangesModelOrder;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class CommitmentController extends Controller
|
||||
{
|
||||
use ChangesModelOrder;
|
||||
|
||||
/**
|
||||
* Create the controller instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->authorizeResource(Commitment::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function index(Request $request): \Illuminate\Contracts\View\View
|
||||
{
|
||||
/** @var \Illuminate\Database\Eloquent\Builder $commitmentModels */
|
||||
$commitmentModels = Commitment::query();
|
||||
|
||||
/** @var string $search Search field */
|
||||
$search = $request->search;
|
||||
if ($search) {
|
||||
$this->searchQuery(
|
||||
$commitmentModels,
|
||||
$search,
|
||||
null,
|
||||
'title',
|
||||
);
|
||||
}
|
||||
$searchFields = \implode(', ', [
|
||||
Str::ucfirst(trans('validation.attributes.title'))
|
||||
]);
|
||||
|
||||
/** Sort columns with a query */
|
||||
$this->sortQuery($commitmentModels);
|
||||
|
||||
/** Custom pagination */
|
||||
$commitmentModels = $this->paginate($commitmentModels);
|
||||
|
||||
return view('bo.pages.commitments.index', compact('commitmentModels', 'search', 'searchFields'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @param \App\Models\Commitment $commitment
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function create(Commitment $commitment): \Illuminate\Contracts\View\View
|
||||
{
|
||||
return view('bo.pages.commitments.create', ['commitmentModel' => $commitment]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \App\Http\Requests\Bo\Commitments\StoreCommitmentRequest $request
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function store(StoreCommitmentRequest $request): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
return DB::transaction(function () use ($request) {
|
||||
$commitment = new Commitment();
|
||||
$commitment->fill($request->validated());
|
||||
|
||||
if ($commitment->saveOrFail()) {
|
||||
return redirect()->route('bo.commitments.edit', $commitment)
|
||||
->with('success', __('crud.messages.has_been_created', [
|
||||
'model' => Str::ucfirst(__('models.classes.commitment'))
|
||||
]));
|
||||
}
|
||||
return redirect()->back()
|
||||
->with('error', __('crud.messages.cannot_be_created', [
|
||||
'model' => Str::ucfirst(__('models.classes.commitment'))
|
||||
]));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param App\Models\Commitment $commitment
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function edit(Commitment $commitment): \Illuminate\Contracts\View\View
|
||||
{
|
||||
return view('bo.pages.commitments.edit', ['commitmentModel' => $commitment]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \App\Http\Requests\Bo\Commitments\UpdateCommitmentRequest $request
|
||||
* @param \App\Models\Commitment $commitment
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function update(UpdateCommitmentRequest $request, Commitment $commitment): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
return DB::transaction(function () use ($request, $commitment) {
|
||||
$commitment->fill($request->validated());
|
||||
|
||||
if ($commitment->saveOrFail()) {
|
||||
return redirect()->route('bo.commitments.edit', $commitment)
|
||||
->with('success', __('crud.messages.has_been_updated', [
|
||||
'model' => Str::ucfirst(__('models.classes.commitment'))
|
||||
]));
|
||||
}
|
||||
return redirect()->route('bo.commitments.edit', $commitment)
|
||||
->with('error', __('crud.messages.cannot_be_updated', [
|
||||
'model' => Str::ucfirst(__('models.classes.commitment'))
|
||||
]));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\Models\Commitment $commitment
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function destroy(Commitment $commitment): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
$commitment->products()->detach();
|
||||
|
||||
if ($commitment->explorerpage()->count() > 3) {
|
||||
if ($commitment->deleteOrFail()) {
|
||||
return redirect()->route('bo.commitments.index')
|
||||
->with('success', __('crud.messages.has_been_deleted', [
|
||||
'model' => Str::ucfirst(__('models.classes.commitment'))
|
||||
]));
|
||||
}
|
||||
}
|
||||
return redirect()->back()
|
||||
->with('error', __('crud.messages.cannot_be_deleted', [
|
||||
'model' => Str::ucfirst(__('models.classes.commitment'))
|
||||
]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Duplicate the specified resource.
|
||||
*
|
||||
* @param \App\Models\Commitment $commitment
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function duplicate(Commitment $commitment): \Illuminate\Contracts\View\View
|
||||
{
|
||||
return $this->create($commitment->replicate());
|
||||
}
|
||||
}
|
||||
53
app/Http/Requests/Bo/Commitments/StoreCommitmentRequest.php
Normal file
53
app/Http/Requests/Bo/Commitments/StoreCommitmentRequest.php
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Bo\Commitments;
|
||||
|
||||
use App\Traits\Requests\HasPicture;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class StoreCommitmentRequest extends FormRequest
|
||||
{
|
||||
use HasPicture;
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return auth('backend')->check();
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare the data for validation.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function prepareForValidation()
|
||||
{
|
||||
$this->merge([
|
||||
'published' => $this->published ? true : false
|
||||
]);
|
||||
$this->mergePicture('picture');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
$rules = [
|
||||
'title' => 'required|string|min:3|max:255',
|
||||
'picture_alt' => 'required|string|min:3|max:255',
|
||||
'picture_title' => 'required|string|min:3|max:255',
|
||||
'published' => 'required|boolean',
|
||||
];
|
||||
return \array_merge(
|
||||
$rules,
|
||||
$this->pictureRules('picture', 185, 185, 185, 185, false),
|
||||
);
|
||||
}
|
||||
}
|
||||
18
app/Http/Requests/Bo/Commitments/UpdateCommitmentRequest.php
Normal file
18
app/Http/Requests/Bo/Commitments/UpdateCommitmentRequest.php
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Bo\Commitments;
|
||||
|
||||
class UpdateCommitmentRequest extends StoreCommitmentRequest
|
||||
{
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return \array_merge(
|
||||
parent::rules()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -65,7 +65,6 @@ class Commitment extends Model
|
|||
static::updated(function (self $model) {
|
||||
FileStorageHelper::removeOldFile($model, 'picture');
|
||||
});
|
||||
|
||||
static::deleted(function (self $model) {
|
||||
FileStorageHelper::removeFile($model, 'picture');
|
||||
});
|
||||
|
|
|
|||
120
app/Policies/CommitmentPolicy.php
Normal file
120
app/Policies/CommitmentPolicy.php
Normal file
|
|
@ -0,0 +1,120 @@
|
|||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Enums\Users\RoleEnum;
|
||||
use App\Models\User;
|
||||
use App\Policies\Rules\UserStaticRules;
|
||||
|
||||
class CommitmentPolicy
|
||||
{
|
||||
/**
|
||||
* Determine whether the user can view any models.
|
||||
*
|
||||
* @param \App\Models\User $authUser
|
||||
* @return boolean
|
||||
*/
|
||||
public function viewAny(User $authUser): bool
|
||||
{
|
||||
return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can view the model.
|
||||
*
|
||||
* @param \App\Models\User $authUser
|
||||
* @return boolean
|
||||
*/
|
||||
public function view(User $authUser): bool
|
||||
{
|
||||
return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can create models.
|
||||
*
|
||||
* @param \App\Models\User $authUser
|
||||
* @return boolean
|
||||
*/
|
||||
public function create(User $authUser): bool
|
||||
{
|
||||
return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can update the model.
|
||||
*
|
||||
* @param \App\Models\User $authUser
|
||||
* @return boolean
|
||||
*/
|
||||
public function update(User $authUser): bool
|
||||
{
|
||||
return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete the model.
|
||||
*
|
||||
* @param \App\Models\User $authUser
|
||||
* @return boolean
|
||||
*/
|
||||
public function delete(User $authUser): bool
|
||||
{
|
||||
return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore the model.
|
||||
*
|
||||
* @param \App\Models\User $authUser
|
||||
* @return boolean
|
||||
*/
|
||||
public function restore(User $authUser): bool
|
||||
{
|
||||
return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete the model.
|
||||
*
|
||||
* @param \App\Models\User $authUser
|
||||
* @return boolean
|
||||
*/
|
||||
public function forceDelete(User $authUser): bool
|
||||
{
|
||||
return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can duplicate the model.
|
||||
*
|
||||
* @param \App\Models\User $authUser
|
||||
* @return boolean
|
||||
*/
|
||||
public function duplicate(User $authUser): bool
|
||||
{
|
||||
return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can publish/unpublish the model.
|
||||
*
|
||||
* @param \App\Models\User $authUser
|
||||
* @return boolean
|
||||
*/
|
||||
public function changePublished(User $authUser): bool
|
||||
{
|
||||
return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can publish/unpublish the model.
|
||||
*
|
||||
* @param \App\Models\User $authUser
|
||||
* @return boolean
|
||||
*/
|
||||
public function changeOrder(User $authUser): bool
|
||||
{
|
||||
return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
|
||||
}
|
||||
}
|
||||
|
|
@ -2,10 +2,12 @@
|
|||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Models\Commitment;
|
||||
use App\Models\Range;
|
||||
use App\Models\News;
|
||||
use App\Models\SeasonalSection;
|
||||
use App\Models\Stamp;
|
||||
use App\Models\News;
|
||||
use App\Models\User;
|
||||
use Illuminate\Cache\RateLimiting\Limit;
|
||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||
|
|
@ -46,10 +48,12 @@ class RouteServiceProvider extends ServiceProvider
|
|||
});
|
||||
|
||||
Route::model('user', User::class);
|
||||
Route::model('commitment', Commitment::class);
|
||||
Route::model('range', Range::class);
|
||||
Route::model('news', News::class);
|
||||
Route::model('seasonal_section', SeasonalSection::class);
|
||||
Route::model('stamp', Stamp::class);
|
||||
Route::model('news', News::class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -16,10 +16,11 @@ class CommitmentSeeder extends Seeder
|
|||
public function run()
|
||||
{
|
||||
FileStorageHelper::removeModelFiles(new Commitment());
|
||||
Commitment::factory(12)->create([
|
||||
'picture' => FileStorageHelper::storeFile(new Commitment(), new \SplFileInfo(\resource_path(
|
||||
Commitment::factory(12)->make()->each(function (Commitment $commitment) {
|
||||
$commitment->picture = FileStorageHelper::storeFile($commitment, new \SplFileInfo(\resource_path(
|
||||
'../database/factories/assets/commitments/default-picture-185x185.png'
|
||||
)))
|
||||
]);
|
||||
)));
|
||||
$commitment->saveOrFail();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,5 +83,12 @@ return [
|
|||
'sort_delete' => 'Delete sorting',
|
||||
'sort_arrow' => 'Here, the arrows are used to sort, not filter.',
|
||||
'right' => 'You don\'t have the rights',
|
||||
]
|
||||
],
|
||||
|
||||
'placeholders' => [
|
||||
'beautiful' => 'A beautiful :field',
|
||||
'crossbreeding' => 'M99 X JA57',
|
||||
'growth_potential' => '2.18 kg at 49 days',
|
||||
],
|
||||
|
||||
];
|
||||
|
|
|
|||
|
|
@ -9,5 +9,6 @@ return [
|
|||
'seasonal_section' => 'seasonal section|seasonal sections',
|
||||
'news' => 'news',
|
||||
'stamp' => 'stamp',
|
||||
'commitment' => 'commitment',
|
||||
]
|
||||
];
|
||||
|
|
|
|||
|
|
@ -241,5 +241,8 @@ return [
|
|||
'publish_at' => 'publication date',
|
||||
'unpublish_at' => 'end of publication date',
|
||||
'background' => 'background',
|
||||
'category' => 'category',
|
||||
'publish_at' => 'publication date',
|
||||
'unpublish_at' => 'end of publication date',
|
||||
],
|
||||
];
|
||||
|
|
|
|||
|
|
@ -91,5 +91,9 @@ return [
|
|||
'sort_delete' => 'Supprimer le tri',
|
||||
'sort_arrow' => 'Ici, les flèches sont utilisées pour trier et non pour filtrer',
|
||||
'right' => 'Vous n\'avez pas les droits',
|
||||
],
|
||||
|
||||
'placeholders' => [
|
||||
'beautiful' => 'Un beau :field',
|
||||
]
|
||||
];
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ return [
|
|||
'user' => 'utilisateur',
|
||||
'activity_log' => 'journal d\'activité|journaux d\'activité',
|
||||
'static_page' => 'page statique|pages statiques',
|
||||
'commitment' => 'engagement',
|
||||
'range' => 'gamme',
|
||||
'seasonal_section' => 'section saisonnière|sections saisonnières',
|
||||
'news' => 'actualité',
|
||||
|
|
|
|||
|
|
@ -12,7 +12,8 @@ return [
|
|||
'alpha_dash' => 'Le champ :attribute doit contenir uniquement des lettres, des chiffres et des tirets.',
|
||||
'alpha_num' => 'Le champ :attribute doit contenir uniquement des chiffres et des lettres.',
|
||||
'array' => 'Le champ :attribute doit être un tableau.',
|
||||
'ascii' => 'Le champ :attribute ne doit contenir que des caractères alphanumériques et des symboles codés sur un octet.',
|
||||
'ascii' => 'Le champ :attribute ne doit contenir que des caractères alphanumériques
|
||||
et des symboles codés sur un octet.',
|
||||
'before' => 'Le champ :attribute doit être une date antérieure au :date.',
|
||||
'before_or_equal' => 'Le champ :attribute doit être une date antérieure ou égale au :date.',
|
||||
'between' => [
|
||||
|
|
@ -108,7 +109,8 @@ return [
|
|||
'mixed' => 'Le champ :attribute doit contenir au moins une majuscule et une minuscule.',
|
||||
'numbers' => 'Le champ :attribute doit contenir au moins un chiffre.',
|
||||
'symbols' => 'Le champ :attribute doit contenir au moins un symbole.',
|
||||
'uncompromised' => 'La valeur du champ :attribute est apparue dans une fuite de données. Veuillez choisir une valeur différente.',
|
||||
'uncompromised' => 'La valeur du champ :attribute est apparue dans une fuite de données.
|
||||
Veuillez choisir une valeur différente.',
|
||||
],
|
||||
'present' => 'Le champ :attribute doit être présent.',
|
||||
'prohibited' => 'Le champ :attribute est interdit.',
|
||||
|
|
@ -241,5 +243,8 @@ return [
|
|||
'publish_at' => 'date de publication',
|
||||
'unpublish_at' => 'date de fin de publication',
|
||||
'background' => 'fond',
|
||||
'category' => 'catégorie',
|
||||
'publish_at' => 'date de publication',
|
||||
'unpublish_at' => 'date de fin de publication',
|
||||
],
|
||||
];
|
||||
|
|
|
|||
|
|
@ -15,10 +15,18 @@
|
|||
</a>
|
||||
</li>
|
||||
@endcan
|
||||
@can('viewAny', \App\Models\Commitment::class)
|
||||
<li class="nav-item">
|
||||
<a class="nav-link @if (request()->routeIs('bo.commitments.*')) active @endif" data-bs-toggle="tooltip"
|
||||
href="{{ route('bo.commitments.index') }}"
|
||||
title="{{ __('crud.helpers.list_all', ['model' => Str::of(__('models.classes.commitment'))->plural()]) }}">
|
||||
{{ Str::of(__('models.classes.commitment'))->plural()->ucfirst() }}
|
||||
</a>
|
||||
</li>
|
||||
@endcan
|
||||
@can('viewAny', \App\Models\Range::class)
|
||||
<li>
|
||||
<a class="nav-link @if (request()->routeIs('bo.ranges.*')) active @endif" data-bs-toggle="tooltip"
|
||||
href="{{ route('bo.ranges.index') }}"
|
||||
<a class="nav-link @if (request()->routeIs('bo.ranges.*')) active @endif" data-bs-toggle="tooltip" href="{{ route('bo.ranges.index') }}"
|
||||
title="{{ __('crud.helpers.list_all', ['model' => Str::plural(__('models.classes.range'))]) }}">
|
||||
{{ Str::of(__('models.classes.range'))->plural()->ucfirst() }}
|
||||
</a>
|
||||
|
|
@ -51,6 +59,15 @@
|
|||
</a>
|
||||
</li>
|
||||
@endcan
|
||||
@can('viewAny', \App\Models\News::class)
|
||||
<li class="nav-item">
|
||||
<a class="nav-link @if (request()->routeIs('bo.news.*')) active @endif" data-bs-toggle="tooltip"
|
||||
href="{{ route('bo.news.index') }}"
|
||||
title="{{ __('crud.helpers.list_all', ['model' => Str::of(__('models.classes.news'))->plural()->title()]) }}">
|
||||
{{ Str::of(__('models.classes.news'))->plural()->title() }}
|
||||
</a>
|
||||
</li>
|
||||
@endcan
|
||||
@canAny(['isConceptor', 'viewAny'], \App\Models\User::class)
|
||||
<li class="nav-item">
|
||||
<div class="dropdown">
|
||||
|
|
@ -78,7 +95,7 @@
|
|||
</li>
|
||||
@endcan
|
||||
</ol>
|
||||
</a>
|
||||
</div>
|
||||
</li>
|
||||
@endcan
|
||||
</ul>
|
||||
|
|
|
|||
36
resources/views/bo/pages/commitments/create.blade.php
Normal file
36
resources/views/bo/pages/commitments/create.blade.php
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
@extends('bo.layout', ['brParam' => $commitmentModel])
|
||||
|
||||
@section('title', trans_choice('crud.meta.title.create', 0, ['model' => __('models.classes.commitment')]))
|
||||
@section('description', trans_choice('crud.meta.description.create', 2, ['model' => __('models.classes.commitment')]))
|
||||
@section('breadcrumb',
|
||||
request()->route()->getName())
|
||||
|
||||
@section('content')
|
||||
<div class="d-flex justify-content-between flex-md-nowrap align-items-center flex-wrap pb-3">
|
||||
<div class="d-flex align-items-start flex-row">
|
||||
<a class="btn btn-primary text-decoration-none m-0" data-bs-toggle="tooltip" href="{{ route('bo.commitments.index') }}"
|
||||
title="{{ __('crud.helpers.list_all', ['model' => __('models.classes.commitment')]) }}">
|
||||
<i class="fa-solid fa-arrow-left"></i>
|
||||
</a>
|
||||
@include('modules.breadcrumbs.breadcrumb-body', ['brParam' => $commitmentModel])
|
||||
</div>
|
||||
<div class="mb-md-0 mb-2">
|
||||
<button class="btn btn-primary" id="formSubmitClone" data-bs-toggle="tooltip" type="submit"
|
||||
title="{{ __('crud.helpers.save_model', ['model' => __('models.classes.commitment')]) }}">
|
||||
{{ Str::ucfirst(__('crud.actions.save')) }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<form action="{{ route('bo.commitments.store') }}" method="POST" enctype="multipart/form-data">
|
||||
@csrf
|
||||
@include('bo.pages.commitments.form')
|
||||
<div class="row mt-3">
|
||||
<div class="col text-center">
|
||||
<button class="btn btn-primary" id="formSubmit" data-bs-toggle="tooltip" type="submit"
|
||||
title="{{ __('crud.helpers.save_model', ['model' => __('models.classes.commitment')]) }}">
|
||||
{{ Str::ucfirst(__('crud.actions.save')) }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
@endsection
|
||||
53
resources/views/bo/pages/commitments/edit.blade.php
Normal file
53
resources/views/bo/pages/commitments/edit.blade.php
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
@extends('bo.layout', ['brParam' => $commitmentModel])
|
||||
|
||||
@section('title', trans_choice('crud.meta.title.edit', 0, ['model' => __('models.classes.commitment')]))
|
||||
@section('description', trans_choice('crud.meta.description.edit', 0, ['model' => __('models.classes.commitment')]))
|
||||
@section('breadcrumb',
|
||||
request()->route()->getName())
|
||||
|
||||
@section('content')
|
||||
<div class="d-flex justify-content-between flex-md-nowrap align-items-center flex-wrap pb-3">
|
||||
<div class="d-flex align-items-start flex-row">
|
||||
<a class="btn btn-primary text-decoration-none m-0" data-bs-toggle="tooltip" href="{{ route('bo.commitments.index') }}"
|
||||
title="{{ __('crud.helpers.list_all', ['model' => Str::plural(__('models.classes.commitment'))]) }}">
|
||||
<i class="fa-solid fa-arrow-left"></i>
|
||||
</a>
|
||||
@include('modules.breadcrumbs.breadcrumb-body', ['brParam' => $commitmentModel])
|
||||
</div>
|
||||
<div class="mb-md-0 mb-2">
|
||||
<form class="btn-group confirmDeleteTS" action="{{ route('bo.commitments.destroy', $commitmentModel) }}" method="POST" novalidate>
|
||||
@can('duplicate', $commitmentModel)
|
||||
<a class="btn btn-secondary" data-bs-toggle="tooltip"
|
||||
href="{{ route('bo.commitments.duplicate', ['commitment' => $commitmentModel]) }}"
|
||||
title="{{ Str::ucfirst(__('crud.actions.duplicate')) }}">
|
||||
<i class="fa-solid fa-copy"></i>
|
||||
</a>
|
||||
@endcan
|
||||
<button class="btn btn-primary" id="formSubmitClone" data-bs-toggle="tooltip" type="submit"
|
||||
title="{{ __('crud.helpers.save_model', ['model' => __('models.classes.commitment')]) }}">
|
||||
{{ Str::ucfirst(__('crud.actions.save')) }}
|
||||
</button>
|
||||
@can('delete', $commitmentModel)
|
||||
@csrf
|
||||
@method('DELETE')
|
||||
<button class="btn btn-danger" data-bs-toggle="tooltip" type="submit" title="{{ Str::ucfirst(__('crud.actions.delete')) }}">
|
||||
<i class="fa-solid fa-trash"></i>
|
||||
</button>
|
||||
@endcan
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<form action="{{ route('bo.commitments.update', $commitmentModel) }}" method="POST" enctype="multipart/form-data">
|
||||
@csrf
|
||||
@method('PUT')
|
||||
@include('bo.pages.commitments.form')
|
||||
<div class="row">
|
||||
<div class="col text-center">
|
||||
<button class="btn btn-primary" id="formSubmit" data-bs-toggle="tooltip" type="submit"
|
||||
title="{{ __('crud.helpers.save_model', ['model' => __('models.classes.commitment')]) }}">
|
||||
{{ Str::ucfirst(__('crud.actions.save')) }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
@endsection
|
||||
146
resources/views/bo/pages/commitments/form.blade.php
Normal file
146
resources/views/bo/pages/commitments/form.blade.php
Normal file
|
|
@ -0,0 +1,146 @@
|
|||
<div class="row">
|
||||
{{-- TITLE --}}
|
||||
<div class="col-12 col-md-6 mb-3">
|
||||
<fieldset class="h-100 border p-3">
|
||||
<legend>{{ Str::ucfirst(__('validation.attributes.title')) }}</legend>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
@include('bo.partials.inputs.varchar', [
|
||||
'id' => 'commitmentTitle',
|
||||
'label' => __(':field :inter:model', [
|
||||
'field' => Str::ucfirst(__('validation.attributes.title')),
|
||||
'inter' => __('validation.custom.of_the.vowel'),
|
||||
'model' => __('models.classes.commitment'),
|
||||
]),
|
||||
'hasWordCounter' => true,
|
||||
'name' => 'title',
|
||||
'required' => true,
|
||||
'model' => $commitmentModel ?? null,
|
||||
'helper' => __('validation.between.string', [
|
||||
'attribute' => __(':field :inter:model', [
|
||||
'field' => __('validation.attributes.title'),
|
||||
'inter' => __('validation.custom.of_the.vowel'),
|
||||
'model' => __('models.classes.commitment'),
|
||||
]),
|
||||
'min' => 3,
|
||||
'max' => 255,
|
||||
]),
|
||||
'placeholder' => __('crud.placeholders.beautiful', ['field' => __('validation.attributes.title')]),
|
||||
])
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
{{-- STATUS --}}
|
||||
<div class="col-12 col-md-6 mb-3">
|
||||
<fieldset class="h-100 border p-3">
|
||||
<legend>{{ __('crud.minicrud.visibility_label') }}</legend>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
@include('bo.partials.inputs.tinyint-boolean', [
|
||||
'id' => 'commitmentStatus',
|
||||
'name' => 'published',
|
||||
'model' => $commitmentModel ?? null,
|
||||
'label' => __('crud.minicrud.visibility_label'),
|
||||
'helper' => sprintf('%s', __('crud.minicrud.visibility_helper')),
|
||||
])
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
|
||||
{{-- PICTURE --}}
|
||||
<div class="col-12 pb-3">
|
||||
<fieldset class="h-100 border p-3">
|
||||
<legend>{{ Str::ucfirst(__('validation.custom.picture')) }}</legend>
|
||||
<div class="row mb-3">
|
||||
{{-- PICTURE_ALT --}}
|
||||
<div class="col-12 col-md-6 m-md-0 mb-3">
|
||||
@include('bo.partials.inputs.varchar', [
|
||||
'id' => 'commitmentPictureAlt',
|
||||
'label' => __(':field1 :inter1:field2 :inter2:model', [
|
||||
'field1' => Str::ucfirst(__('validation.custom.attribute_alt')),
|
||||
'inter1' => __('validation.custom.of_the.vowel'),
|
||||
'field2' => __('validation.custom.picture'),
|
||||
'inter2' => __('validation.custom.of_the.vowel'),
|
||||
'model' => __('models.classes.commitment'),
|
||||
]),
|
||||
'hasWordCounter' => true,
|
||||
'name' => 'picture_alt',
|
||||
'required' => true,
|
||||
'model' => $commitmentModel ?? null,
|
||||
'helper' => __('crud.minicrud.picture_alt_helper'),
|
||||
'placeholder' => __(':field1 :inter1:field2 :inter2:model', [
|
||||
'field1' => Str::ucfirst(__('validation.custom.attribute_alt')),
|
||||
'inter1' => __('validation.custom.of_the.vowel'),
|
||||
'field2' => __('validation.custom.picture'),
|
||||
'inter2' => __('validation.custom.of_the.vowel'),
|
||||
'model' => __('models.classes.commitment'),
|
||||
]),
|
||||
])
|
||||
</div>
|
||||
{{-- PICTURE_TITLE --}}
|
||||
<div class="col-12 col-md-6 mb-3">
|
||||
@include('bo.partials.inputs.varchar', [
|
||||
'id' => 'commitmentPictureTitle',
|
||||
'label' => __(':field1 :inter1:field2 :inter2:model', [
|
||||
'field1' => Str::ucfirst(__('validation.custom.attribute_title')),
|
||||
'inter1' => __('validation.custom.of_the.vowel'),
|
||||
'field2' => __('validation.custom.picture'),
|
||||
'inter2' => __('validation.custom.of_the.vowel'),
|
||||
'model' => __('models.classes.commitment'),
|
||||
]),
|
||||
'hasWordCounter' => true,
|
||||
'name' => 'picture_title',
|
||||
'required' => true,
|
||||
'model' => $commitmentModel ?? null,
|
||||
'helper' => __('crud.minicrud.picture_title_helper'),
|
||||
'placeholder' => __(':field1 :inter1:field2 :inter2:model', [
|
||||
'field1' => Str::ucfirst(__('validation.custom.attribute_title')),
|
||||
'inter1' => __('validation.custom.of_the.vowel'),
|
||||
'field2' => __('validation.custom.picture'),
|
||||
'inter2' => __('validation.custom.of_the.vowel'),
|
||||
'model' => __('models.classes.commitment'),
|
||||
]),
|
||||
])
|
||||
</div>
|
||||
{{-- PICTURE --}}
|
||||
<div class="col-12">
|
||||
@include('bo.partials.inputs.varchar-picture', [
|
||||
'id' => 'commitmentPicture',
|
||||
'name' => 'picture',
|
||||
'width' => 185,
|
||||
'height' => 185,
|
||||
'model' => $commitmentModel ?? null,
|
||||
'helper' => __('crud.minicrud.dimensions_must_be', [
|
||||
'widthpx' => '185px',
|
||||
'heightpx' => '185px',
|
||||
]),
|
||||
'required' => true,
|
||||
'preview' => true,
|
||||
])
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col text-center">
|
||||
<p><b>* {{ __('crud.helpers.required_fields') }}</b></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@push('scripts')
|
||||
<script nonce="{{ $nonce }}">
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
// Submit button clone.
|
||||
const submit = document.getElementById('formSubmit')
|
||||
submitClone = document.getElementById('formSubmitClone');
|
||||
submitClone.addEventListener('click', (event) => {
|
||||
event.preventDefault();
|
||||
submit.click('');
|
||||
})
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
77
resources/views/bo/pages/commitments/index-list.blade.php
Normal file
77
resources/views/bo/pages/commitments/index-list.blade.php
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
<table class="table-hover table-fix-action m-0 table">
|
||||
@if (count($commitmentModels) > 0)
|
||||
<thead>
|
||||
@include('bo.modules.table-col-sorter', [
|
||||
'cols' => [
|
||||
'title' => Str::ucfirst(__('validation.attributes.title')),
|
||||
'picture' => Str::ucfirst(__('validation.custom.picture')),
|
||||
'updated_at' => Str::ucfirst(__('validation.attributes.updated_at')),
|
||||
'order' => Str::ucfirst(__('validation.custom.order')),
|
||||
],
|
||||
])
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($commitmentModels as $commitmentModel)
|
||||
<tr class="border-bottom list-item">
|
||||
<td class="text-center align-middle">{{ $commitmentModel->title }}</td>
|
||||
<td class="text-center align-middle">
|
||||
<img src="{{ asset($commitmentModel->picture) }}" title="{{ $commitmentModel->picture_title }}"
|
||||
alt="{{ $commitmentModel->picture_alt }}" height="50px">
|
||||
</td>
|
||||
<td class="text-center align-middle">
|
||||
<span class="badge bg-secondary">{{ $commitmentModel->updated_at->isoFormat('LLLL') }}</span>
|
||||
</td>
|
||||
@php
|
||||
$routeName = request()
|
||||
->route()
|
||||
->getName();
|
||||
@endphp
|
||||
@if (empty(request()->search) && Session::get("$routeName.sort_col") === 'order')
|
||||
@include('bo.modules.change-model-order', [
|
||||
'routeName' => 'commitments',
|
||||
'model' => $commitmentModel,
|
||||
'models' => $commitmentModels,
|
||||
])
|
||||
@endif
|
||||
<td class="text-end align-middle">
|
||||
@canAny(['delete', 'duplicate', 'update'], $commitmentModel)
|
||||
<form class="btn-group confirmDeleteTS" action="{{ route('bo.commitments.destroy', $commitmentModel) }}"
|
||||
method="POST" novalidate>
|
||||
@can('duplicate', $commitmentModel)
|
||||
<a class="btn btn-sm btn-secondary" data-bs-toggle="tooltip"
|
||||
href="{{ route('bo.commitments.duplicate', ['commitment' => $commitmentModel]) }}"
|
||||
title="{{ Str::ucfirst(__('crud.actions.duplicate')) }}">
|
||||
<i class="fa-solid fa-copy"></i>
|
||||
</a>
|
||||
@endcan
|
||||
@can('update', $commitmentModel)
|
||||
<a class="btn btn-sm btn-primary" data-bs-toggle="tooltip"
|
||||
href="{{ route('bo.commitments.edit', ['commitment' => $commitmentModel]) }}"
|
||||
title="{{ Str::ucfirst(__('crud.actions.update')) }}">
|
||||
<i class="fa-solid fa-pencil"></i>
|
||||
</a>
|
||||
@endcan
|
||||
@can('delete', $commitmentModel)
|
||||
@csrf
|
||||
@method('DELETE')
|
||||
<button class="btn btn-sm btn-danger" data-bs-toggle="tooltip" type="submit"
|
||||
title="{{ Str::ucfirst(__('crud.actions.delete')) }}">
|
||||
<i class="fa-solid fa-trash"></i>
|
||||
</button>
|
||||
@endcan
|
||||
</form>
|
||||
@else
|
||||
<span class="text-danger" data-bs-toggle="tooltip" title="{{ __('list.right') }}">
|
||||
<i class="fa-solid fa-ban"></i>
|
||||
</span>
|
||||
@endcan
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
@else
|
||||
<tr>
|
||||
<td class="border-0">{{ __('crud.other.no_model_found', ['model' => __('models.classes.commitment')]) }}</td>
|
||||
</tr>
|
||||
@endif
|
||||
</table>
|
||||
22
resources/views/bo/pages/commitments/index.blade.php
Normal file
22
resources/views/bo/pages/commitments/index.blade.php
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
@extends('bo.layout')
|
||||
|
||||
@section('title',
|
||||
Str::of(__('models.classes.commitment'))->plural()->ucfirst())
|
||||
@section('description', trans_choice('crud.meta.description.index', 0, ['model' => Str::plural(__('models.classes.commitment'))]))
|
||||
|
||||
@section('content')
|
||||
<div class="d-flex justify-content-between flex-md-nowrap align-items-center flex-wrap">
|
||||
@include('modules.breadcrumbs.breadcrumb-body')
|
||||
@can('create', \App\Models\Commitment::class)
|
||||
<a class="btn btn-primary float-right" data-bs-toggle="tooltip" href="{{ route('bo.commitments.create') }}"
|
||||
title="{{ __('crud.helpers.create_model', ['model' => __('models.classes.commitment')]) }}">
|
||||
<i class="fa-solid fa-plus"></i>
|
||||
</a>
|
||||
@endcan
|
||||
</div>
|
||||
@include('bo.modules.search-bar')
|
||||
<div class="table-responsive mb-3">
|
||||
@include('bo.pages.commitments.index-list')
|
||||
</div>
|
||||
{{ $commitmentModels->links() }}
|
||||
@endsection
|
||||
|
|
@ -1,10 +1,12 @@
|
|||
<?php
|
||||
|
||||
use App\Models\ActivityLog;
|
||||
use App\Models\Commitment;
|
||||
use App\Models\Range;
|
||||
use App\Models\News;
|
||||
use App\Models\SeasonalSection;
|
||||
use App\Models\Stamp;
|
||||
use App\Models\News;
|
||||
use App\Models\StaticPage;
|
||||
use App\Models\User;
|
||||
use Diglactic\Breadcrumbs\Breadcrumbs;
|
||||
|
|
@ -31,6 +33,26 @@ Breadcrumbs::for('bo.users.duplicate', function (Generator $trail) {
|
|||
$trail->push(Str::ucfirst(trans('crud.actions.duplicate')));
|
||||
});
|
||||
|
||||
// * COMMITMENTS
|
||||
Breadcrumbs::for('bo.commitments.index', function (Generator $trail) {
|
||||
$trail->push(
|
||||
Str::of(trans('models.classes.commitment'))->plural()->ucfirst(),
|
||||
route('bo.commitments.index', ['sort_col' => 'updated_at', 'sort_way' => 'desc'])
|
||||
);
|
||||
});
|
||||
Breadcrumbs::for('bo.commitments.create', function (Generator $trail) {
|
||||
$trail->parent('bo.commitments.index');
|
||||
$trail->push(Str::ucfirst(trans('crud.actions.create')), route('bo.commitments.create'));
|
||||
});
|
||||
Breadcrumbs::for('bo.commitments.edit', function (Generator $trail, Commitment $commitment) {
|
||||
$trail->parent('bo.commitments.index');
|
||||
$trail->push(Str::ucfirst(trans('crud.actions.edit')), route('bo.commitments.edit', $commitment));
|
||||
});
|
||||
Breadcrumbs::for('bo.commitments.duplicate', function (Generator $trail) {
|
||||
$trail->parent('bo.commitments.index');
|
||||
$trail->push(Str::ucfirst(trans('crud.actions.duplicate')));
|
||||
});
|
||||
|
||||
// * ACTIVITY_LOGS
|
||||
Breadcrumbs::for('bo.activity_logs.index', function (Generator $trail) {
|
||||
$trail->push(
|
||||
|
|
@ -134,3 +156,23 @@ Breadcrumbs::for('bo.stamps.duplicate', function (Generator $trail) {
|
|||
$trail->parent('bo.stamps.index');
|
||||
$trail->push(Str::ucfirst(trans('crud.actions.duplicate')));
|
||||
});
|
||||
|
||||
// * NEWS
|
||||
Breadcrumbs::for('bo.news.index', function (Generator $trail) {
|
||||
$trail->push(
|
||||
Str::of(trans('models.classes.news'))->plural()->ucfirst(),
|
||||
route('bo.news.index', ['sort_col' => 'updated_at', 'sort_way' => 'desc'])
|
||||
);
|
||||
});
|
||||
Breadcrumbs::for('bo.news.create', function (Generator $trail) {
|
||||
$trail->parent('bo.news.index');
|
||||
$trail->push(Str::ucfirst(trans('crud.actions.create')), route('bo.news.create'));
|
||||
});
|
||||
Breadcrumbs::for('bo.news.edit', function (Generator $trail, News $news) {
|
||||
$trail->parent('bo.news.index');
|
||||
$trail->push(Str::ucfirst(trans('crud.actions.edit')), route('bo.news.edit', $news));
|
||||
});
|
||||
Breadcrumbs::for('bo.news.duplicate', function (Generator $trail) {
|
||||
$trail->parent('bo.news.index');
|
||||
$trail->push(Str::ucfirst(trans('crud.actions.duplicate')));
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
|
||||
use App\Http\Controllers\Bo\ActivityLogsController;
|
||||
use App\Http\Controllers\Bo\CommitmentController;
|
||||
use App\Http\Controllers\Bo\DashboardController;
|
||||
use App\Http\Controllers\Bo\NewsController;
|
||||
use App\Http\Controllers\Bo\StaticPageController;
|
||||
|
|
@ -41,6 +42,18 @@ Route::prefix('bo')
|
|||
UsersController::class, 'duplicate'
|
||||
])->name('users.duplicate');
|
||||
|
||||
// * COMMITMENTS
|
||||
Route::resource('commitments', CommitmentController::class)->except(['show'])
|
||||
->withoutMiddleware('htmlsanitize')
|
||||
->middleware('htmlsanitize:content');
|
||||
Route::get('/commitments/{commitment}/duplicate', [
|
||||
CommitmentController::class, 'duplicate'
|
||||
])->name('commitments.duplicate');
|
||||
// Change order.
|
||||
Route::patch('/commitments/{commitment}/change-order/{direction}', [
|
||||
CommitmentController::class, 'changeOrder'
|
||||
])->where('direction', 'up|down')->name('commitments.change-order');
|
||||
|
||||
// * STATIC_PAGES
|
||||
Route::resource('pages', StaticPageController::class)
|
||||
->names([
|
||||
|
|
@ -107,6 +120,20 @@ Route::prefix('bo')
|
|||
StampController::class, 'duplicate'
|
||||
])->name('stamps.duplicate');
|
||||
|
||||
// * NEWS.
|
||||
Route::resource('news', NewsController::class)->except('show')
|
||||
->withoutMiddleware('htmlsanitize')
|
||||
->middleware('htmlsanitize:content');
|
||||
Route::patch('/news/{news}/change-published', [
|
||||
NewsController::class, 'changePublished'
|
||||
])->name('news.change-published');
|
||||
Route::patch('/news/{news}/change-order/{direction}', [
|
||||
RangeController::class, 'changeOrder'
|
||||
])->where('direction', 'up|down')->name('news.change-order');
|
||||
Route::get('/news/{news}/duplicate', [
|
||||
NewsController::class, 'duplicate'
|
||||
])->name('news.duplicate');
|
||||
|
||||
Route::middleware('can:isConceptor')->group(function () {
|
||||
// * ACTIVITY LOGS.
|
||||
Route::resource('activity_logs', ActivityLogsController::class)->only(['index', 'show']);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue