update bo conviction: remove index page and redirect to the edit
This commit is contained in:
parent
5f90384be4
commit
2648256177
8 changed files with 32 additions and 151 deletions
|
|
@ -10,65 +10,44 @@ use Illuminate\Support\Str;
|
|||
|
||||
class ConvictionpageController extends Controller
|
||||
{
|
||||
/**
|
||||
* Create the controller instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->authorizeResource(Convictionpage::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function index(): \Illuminate\Contracts\View\View
|
||||
{
|
||||
/** @var \Illuminate\Database\Eloquent\Builder $convictionpageModels */
|
||||
$convictionpageModels = Convictionpage::query();
|
||||
|
||||
/** Sort columns with a query */
|
||||
$this->sortQuery($convictionpageModels);
|
||||
|
||||
/** Custom pagination */
|
||||
$convictionpageModels = $this->paginate($convictionpageModels);
|
||||
|
||||
return view('bo.pages.convictionpages.index', compact('convictionpageModels'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param App\Models\Convictionpage $convictionpage
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function edit(Convictionpage $convictionpage): \Illuminate\Contracts\View\View
|
||||
public function edit(): \Illuminate\Contracts\View\View
|
||||
{
|
||||
return view('bo.pages.convictionpages.edit', ['convictionpageModel' => $convictionpage]);
|
||||
$this->authorize('update', \App\Models\Convictionpage::class);
|
||||
|
||||
/** @var \App\Models\Convictionpage $convictionpageModel */
|
||||
$convictionpageModel = Convictionpage::query()->firstOrFail();
|
||||
|
||||
return view('bo.pages.convictionpages.edit', compact('convictionpageModel'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \App\Http\Requests\Bo\Convictionpages\UpdateConvictionpageRequest $request
|
||||
* @param \App\Models\Convictionpage $convictionpage
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function update(
|
||||
UpdateConvictionpageRequest $request,
|
||||
Convictionpage $convictionpage
|
||||
): \Illuminate\Http\RedirectResponse {
|
||||
return DB::transaction(function () use ($request, $convictionpage) {
|
||||
$convictionpage->fill($request->validated());
|
||||
public function update(UpdateConvictionpageRequest $request): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
$this->authorize('update', \App\Models\Convictionpage::class);
|
||||
|
||||
if ($convictionpage->saveOrFail()) {
|
||||
return redirect()->route('bo.convictionpages.edit', $convictionpage)
|
||||
return DB::transaction(function () use ($request) {
|
||||
/** @var \App\Models\Convictionpage $convictionpageModel */
|
||||
$convictionpageModel = Convictionpage::query()->firstOrFail();
|
||||
|
||||
$convictionpageModel->fill($request->validated());
|
||||
|
||||
if ($convictionpageModel->saveOrFail()) {
|
||||
return redirect()->route('bo.convictionpages.edit')
|
||||
->with('success', __('crud.messages.has_been_updated', [
|
||||
'model' => Str::ucfirst(__('models.classes.convictionpage'))
|
||||
]));
|
||||
}
|
||||
return redirect()->route('bo.convictionpages.edit', $convictionpage)
|
||||
return redirect()->route('bo.convictionpages.edit')
|
||||
->with('error', __('crud.messages.cannot_be_updated', [
|
||||
'model' => Str::ucfirst(__('models.classes.convictionpage'))
|
||||
]));
|
||||
|
|
|
|||
|
|
@ -19,17 +19,6 @@ class ConvictionpagePolicy
|
|||
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 update the model.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@
|
|||
@can('viewAny', \App\Models\Convictionpage::class)
|
||||
<li>
|
||||
<a class="nav-link @if (request()->routeIs('bo.convictionpages.*')) active @endif" data-bs-toggle="tooltip"
|
||||
href="{{ route('bo.convictionpages.index') }}"
|
||||
href="{{ route('bo.convictionpages.edit') }}"
|
||||
title="{{ trans_choice('crud.meta.title.edit', 1, ['model' => __('models.classes.convictionpage')]) }}">
|
||||
{{ Str::of(__('models.classes.convictionpage'))->ucfirst() }}
|
||||
</a>
|
||||
|
|
|
|||
|
|
@ -8,23 +8,16 @@
|
|||
@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.convictionpages.index') }}"
|
||||
title="{{ __('crud.helpers.list_all', ['model' => Str::plural(__('models.classes.convictionpage'))]) }}">
|
||||
<i class="fa-solid fa-arrow-left"></i>
|
||||
</a>
|
||||
@include('modules.breadcrumbs.breadcrumb-body', ['brParam' => $convictionpageModel])
|
||||
</div>
|
||||
<div class="mb-md-0 mb-2">
|
||||
<form class="btn-group confirmDeleteTS" action="{{ route('bo.convictionpages.edit', $convictionpageModel) }}" method="POST"
|
||||
novalidate>
|
||||
<button class="btn btn-primary" id="formSubmitClone" data-bs-toggle="tooltip" type="submit"
|
||||
title="{{ __('crud.helpers.save_model', ['model' => __('models.classes.convictionpage')]) }}">
|
||||
{{ Str::ucfirst(__('crud.actions.save')) }}
|
||||
</button>
|
||||
</form>
|
||||
<button class="btn btn-primary" id="formSubmitClone" data-bs-toggle="tooltip" type="submit"
|
||||
title="{{ __('crud.helpers.save_model', ['model' => __('models.classes.convictionpage')]) }}">
|
||||
{{ Str::ucfirst(__('crud.actions.save')) }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<form action="{{ route('bo.convictionpages.update', $convictionpageModel) }}" method="POST" enctype="multipart/form-data">
|
||||
<form action="{{ route('bo.convictionpages.update') }}" method="POST" enctype="multipart/form-data">
|
||||
@csrf
|
||||
@method('PUT')
|
||||
@include('bo.pages.convictionpages.form')
|
||||
|
|
|
|||
|
|
@ -1,63 +0,0 @@
|
|||
<table class="table-hover table-fix-action m-0 table">
|
||||
@if (count($convictionpageModels) > 0)
|
||||
<thead>
|
||||
@include('bo.modules.table-col-sorter', [
|
||||
'cols' => [
|
||||
'key_feed' => Str::ucfirst(__('validation.custom.key_feed')),
|
||||
'key_earth_1' => Str::ucfirst(__('validation.custom.key_earth_1')),
|
||||
'key_earth_2' => Str::ucfirst(__('validation.custom.key_earth_2')),
|
||||
'key_together_1' => Str::ucfirst(__('validation.custom.key_together_1')),
|
||||
'key_together_2' => Str::ucfirst(__('validation.custom.key_together_2')),
|
||||
'key_together_3' => Str::ucfirst(__('validation.custom.key_together_3')),
|
||||
'key_together_4' => Str::ucfirst(__('validation.custom.key_together_4')),
|
||||
'key_territory' => Str::ucfirst(__('validation.custom.key_territory')),
|
||||
'updated_at' => Str::ucfirst(__('validation.attributes.updated_at')),
|
||||
],
|
||||
])
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($convictionpageModels as $convictionpageModel)
|
||||
<tr class="border-bottom list-item">
|
||||
<td class="text-center align-middle">{{ $convictionpageModel->key_feed }}</td>
|
||||
<td class="text-center align-middle">{{ $convictionpageModel->key_earth_1 }}</td>
|
||||
<td class="text-center align-middle">{{ $convictionpageModel->key_earth_2 }}</td>
|
||||
<td class="text-center align-middle">{{ $convictionpageModel->key_together_1 }}</td>
|
||||
<td class="text-center align-middle">{{ $convictionpageModel->key_together_2 }}</td>
|
||||
<td class="text-center align-middle">{{ $convictionpageModel->key_together_3 }}</td>
|
||||
<td class="text-center align-middle">{{ $convictionpageModel->key_together_4 }}</td>
|
||||
<td class="text-center align-middle">{{ $convictionpageModel->key_territory }}</td>
|
||||
<td class="text-center align-middle">
|
||||
<span class="badge bg-secondary">{{ $convictionpageModel->updated_at->isoFormat('LLLL') }}</span>
|
||||
</td>
|
||||
@php
|
||||
$routeName = request()
|
||||
->route()
|
||||
->getName();
|
||||
@endphp
|
||||
<td class="text-end align-middle">
|
||||
@canAny(['update'], $convictionpageModel)
|
||||
<form class="btn-group confirmDeleteTS" action="{{ route('bo.convictionpages.edit', $convictionpageModel) }}"
|
||||
method="POST" novalidate>
|
||||
@can('update', $convictionpageModel)
|
||||
<a class="btn btn-sm btn-primary" data-bs-toggle="tooltip"
|
||||
href="{{ route('bo.convictionpages.edit', ['convictionpage' => $convictionpageModel]) }}"
|
||||
title="{{ Str::ucfirst(__('crud.actions.update')) }}">
|
||||
<i class="fa-solid fa-pencil"></i>
|
||||
</a>
|
||||
@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.convictionpage')]) }}</td>
|
||||
</tr>
|
||||
@endif
|
||||
</table>
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
@extends('bo.layout')
|
||||
|
||||
@section('title',
|
||||
Str::of(__('models.classes.convictionpage'))->plural()->ucfirst())
|
||||
@section('description', trans_choice('crud.meta.description.index', 0, ['model' => Str::plural(__('models.classes.convictionpage'))]))
|
||||
|
||||
@section('content')
|
||||
<div class="d-flex justify-content-between flex-md-nowrap align-items-center flex-wrap">
|
||||
@include('modules.breadcrumbs.breadcrumb-body')
|
||||
</div>
|
||||
|
||||
<div class="table-responsive mb-3">
|
||||
@include('bo.pages.convictionpages.index-list')
|
||||
</div>
|
||||
{{ $convictionpageModels->links() }}
|
||||
@endsection
|
||||
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
use App\Models\ActivityLog;
|
||||
use App\Models\Commitment;
|
||||
use App\Models\Convictionpage;
|
||||
use App\Models\Joinuspage;
|
||||
use App\Models\Range;
|
||||
use App\Models\News;
|
||||
|
|
@ -212,14 +211,11 @@ Breadcrumbs::for('bo.products.duplicate', function (Generator $trail) {
|
|||
|
||||
// * CONVICTIONPAGES
|
||||
Breadcrumbs::for('bo.convictionpages.index', function (Generator $trail) {
|
||||
$trail->push(
|
||||
Str::of(trans('models.classes.convictionpage'))->plural()->ucfirst(),
|
||||
route('bo.convictionpages.index', ['sort_col' => 'updated_at', 'sort_way' => 'desc'])
|
||||
);
|
||||
$trail->push(Str::ucfirst(trans('models.classes.explorerpage')));
|
||||
});
|
||||
Breadcrumbs::for('bo.convictionpages.edit', function (Generator $trail, Convictionpage $convictionpage) {
|
||||
Breadcrumbs::for('bo.convictionpages.edit', function (Generator $trail) {
|
||||
$trail->parent('bo.convictionpages.index');
|
||||
$trail->push(Str::ucfirst(trans('crud.actions.edit')), route('bo.convictionpages.edit', $convictionpage));
|
||||
$trail->push(Str::ucfirst(trans('crud.actions.edit')));
|
||||
});
|
||||
|
||||
// * TESTIMONIALS
|
||||
|
|
|
|||
|
|
@ -153,7 +153,10 @@ Route::prefix('bo')
|
|||
])->name('products.duplicate');
|
||||
|
||||
// * CONVICTIONPAGES
|
||||
Route::resource('convictionpages', ConvictionpageController::class)->only(['index', 'edit', 'update']);
|
||||
Route::get('/convictionpages/edit', [ConvictionpageController::class, 'edit'])
|
||||
->name('convictionpages.edit');
|
||||
Route::put('/convictionpages/update', [ConvictionpageController::class, 'update'])
|
||||
->name('convictionpages.update');
|
||||
|
||||
// * JOINUSPAGES
|
||||
Route::resource('joinuspages', JoinuspageController::class)->only(['index', 'edit', 'update']);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue