fix: ⚡ improve bo pagination #46
This commit is contained in:
parent
3ab1a2244e
commit
ecc2b7059e
21 changed files with 189 additions and 152 deletions
|
|
@ -51,7 +51,7 @@ class ActivityLogsController extends Controller
|
|||
$this->sortQuery($query);
|
||||
|
||||
/** Custom pagination */
|
||||
$activitylogModels = $this->paginate($query);
|
||||
$activitylogModels = $query->paginate($this->getPagination());
|
||||
|
||||
return view('bo.pages.activity_logs.index', compact('activitylogModels', 'search', 'searchFields'));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,22 +32,22 @@ class AnswerController extends Controller
|
|||
/** @var \App\Models\Question $questionModel */
|
||||
$questionModel = $request->question;
|
||||
|
||||
/** @var \Illuminate\Database\Eloquent\Builder $answers */
|
||||
$answers = Answer::query()->where('question_id', $questionModel->id);
|
||||
/** @var \Illuminate\Database\Eloquent\Builder $query */
|
||||
$query = Answer::query()->where('question_id', $questionModel->id);
|
||||
|
||||
if ($request->search) {
|
||||
$this->searchQuery(
|
||||
$answers,
|
||||
$query,
|
||||
$request->search,
|
||||
null,
|
||||
'answer',
|
||||
);
|
||||
}
|
||||
|
||||
$this->sortQuery($answers);
|
||||
$this->sortQuery($query);
|
||||
$searchFields = trans('Réponse');
|
||||
|
||||
$answerModels = $this->paginate($answers);
|
||||
$answerModels = $this->paginate($this->getPagination());
|
||||
|
||||
return view('bo.pages.answers.index', compact('answerModels', 'questionModel', 'searchFields'));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ class BrandController extends Controller
|
|||
$q->where('opt_in', true);
|
||||
}]);
|
||||
|
||||
$brandModels = $this->paginate($query);
|
||||
$brandModels = $query->paginate($this->getPagination());
|
||||
|
||||
return view('bo.pages.brands.index', compact('brandModels', 'searchFields'));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,8 +45,8 @@ class ClaimController extends Controller
|
|||
/** @var \App\Models\User $userModel */
|
||||
$userModel = auth('backend')->user();
|
||||
|
||||
/** @var \Illuminate\Database\Eloquent\Builder $claimModels */
|
||||
$claimModels = Claim::query()
|
||||
/** @var \Illuminate\Database\Eloquent\Builder $query */
|
||||
$query = Claim::query()
|
||||
->when(
|
||||
$request->filled('brand'),
|
||||
fn($q) => $q->whereHas('brand', fn($q) => $q->where('id', $request->brand))
|
||||
|
|
@ -59,7 +59,7 @@ class ClaimController extends Controller
|
|||
$search = $request->search;
|
||||
if ($search) {
|
||||
$this->searchQuery(
|
||||
$claimModels,
|
||||
$query,
|
||||
$search,
|
||||
null,
|
||||
'reference',
|
||||
|
|
@ -76,10 +76,10 @@ class ClaimController extends Controller
|
|||
]);
|
||||
|
||||
/** Sort columns with a query */
|
||||
$this->sortQuery($claimModels);
|
||||
$this->sortQuery($query);
|
||||
|
||||
/** Custom pagination */
|
||||
$claimModels = $this->paginate($claimModels);
|
||||
$claimModels = $query->simplePaginate($this->getPagination());
|
||||
|
||||
return view('bo.pages.claims.index', compact('claimModels', 'search', 'searchFields'));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ class ClaimMailTemplateController extends Controller
|
|||
$this->sortQuery($query);
|
||||
$searchFields = trans('validation.custom.label');
|
||||
|
||||
$claimMailTemplateModels = $this->paginate($query);
|
||||
$claimMailTemplateModels = $query->paginate($this->getPagination());
|
||||
|
||||
return view('bo.pages.claim_mail_templates.index', compact('claimMailTemplateModels', 'searchFields'));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ class ClaimSubjectController extends Controller
|
|||
$this->sortQuery($query);
|
||||
$searchFields = trans('validation.custom.label');
|
||||
|
||||
$claimSubjectModels = $this->paginate($query);
|
||||
$claimSubjectModels = $query->paginate($this->getPagination());
|
||||
|
||||
return view('bo.pages.claim_subjects.index', compact('claimSubjectModels', 'searchFields'));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,10 +42,11 @@ class CustomerController extends Controller
|
|||
*/
|
||||
public function index(Request $request): \Illuminate\Contracts\View\View
|
||||
{
|
||||
$modelClass = Customer::class;
|
||||
$modelTable = (new Customer())->getTable();
|
||||
$brands = Brand::select('id', 'name')->get();
|
||||
$columns = ['customer_infos.lastname', 'customer_infos.firstname'];
|
||||
$modelClass = Customer::class;
|
||||
$modelTable = (new Customer())->getTable();
|
||||
$questionModels = null;
|
||||
$answerModels = null;
|
||||
$searchFields = trans('Email, Prénom, Nom');
|
||||
|
||||
// Reset session sorts.
|
||||
if ($request->rstSrts) {
|
||||
|
|
@ -56,27 +57,26 @@ class CustomerController extends Controller
|
|||
$this->resetSessionFilters($modelTable);
|
||||
}
|
||||
|
||||
$query = $this->buildCustomerQuery();
|
||||
if ($request->filled('search') || Session::get("crud.$modelTable.search")) {
|
||||
$columns = ['customer_infos.lastname', 'customer_infos.firstname'];
|
||||
$query = $this->buildCustomerQuery();
|
||||
|
||||
// Apply filters.
|
||||
$questionModels = null;
|
||||
$answerModels = null;
|
||||
$this->applyBrandFilter($request, $query, $modelTable, $questionModels, $answerModels);
|
||||
$this->applySearchFilter($request, $query, $modelTable, $columns);
|
||||
$this->applySort($request, $query, $modelTable);
|
||||
// Apply filters.
|
||||
$this->applyBrandFilter($request, $query, $modelTable, $questionModels, $answerModels);
|
||||
$this->applySearchFilter($request, $query, $modelTable, $columns);
|
||||
$this->applySort($request, $query, $modelTable);
|
||||
|
||||
$customerModels = $this->paginate($query->with(['customer', 'brand']));
|
||||
$searchFields = trans('Email, Prénom, Nom');
|
||||
$customerModels = $query->with(['customer', 'brand'])->simplePaginate($this->getPagination());
|
||||
} //end if
|
||||
|
||||
return view('bo.pages.customers.index', compact(
|
||||
'modelClass',
|
||||
'modelTable',
|
||||
'customerModels',
|
||||
'brands',
|
||||
'searchFields',
|
||||
'questionModels',
|
||||
'answerModels',
|
||||
));
|
||||
return view('bo.pages.customers.index', [
|
||||
'modelClass' => $modelClass,
|
||||
'modelTable' => $modelTable,
|
||||
'customerModels' => $customerModels ?? collect(),
|
||||
'searchFields' => $searchFields,
|
||||
'questionModels' => $questionModels,
|
||||
'answerModels' => $answerModels,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -330,34 +330,35 @@ class CustomerController extends Controller
|
|||
?Collection &$questionModels,
|
||||
?Collection &$answerModels
|
||||
): void {
|
||||
if ($request->filled('brand') || Session::has("crud.$table.brand")) {
|
||||
$brand = $request->brand ?? Session::get("crud.$table.brand");
|
||||
Session::put("crud.$table.brand", $brand);
|
||||
$query->where('customer_infos.brand_id', $brand);
|
||||
$brand = $request->brand ?? Session::get("crud.$table.brand");
|
||||
if (!(int) $brand) {
|
||||
return;
|
||||
}
|
||||
Session::put("crud.$table.brand", $brand);
|
||||
$query->where('customer_infos.brand_id', $brand);
|
||||
|
||||
$questionModels = Question::getAllModelsFromBrand($brand);
|
||||
$questionModels = Question::getAllModelsFromBrand($brand);
|
||||
|
||||
if (($request->filled('question') || Session::has("crud.$table.question")) && $questionModels->count()) {
|
||||
$question = $request->question ?? Session::get("crud.$table.question");
|
||||
Session::put("crud.$table.question", $question);
|
||||
if (($request->filled('question') || Session::has("crud.$table.question")) && $questionModels->count()) {
|
||||
$question = $request->question ?? Session::get("crud.$table.question");
|
||||
Session::put("crud.$table.question", $question);
|
||||
|
||||
$answerModels = Answer::getAllAnswersFromQuestion($question);
|
||||
$questionAnswers = Question::find($question)?->answers->modelKeys() ?? [];
|
||||
$answerModels = Answer::getAllAnswersFromQuestion($question);
|
||||
$questionAnswers = Question::find($question)?->answers->modelKeys() ?? [];
|
||||
|
||||
$query->whereHas('customer.answers', fn($q) => $q->whereIn('answer_id', $questionAnswers));
|
||||
$query->whereHas('customer.answers', fn($q) => $q->whereIn('answer_id', $questionAnswers));
|
||||
|
||||
if (
|
||||
($request->filled('answer') || Session::has("crud.$table.answer"))
|
||||
&& $questionModels->count()
|
||||
&& $answerModels->count()
|
||||
) {
|
||||
$answer = $request->answer ?? Session::get("crud.$table.answer");
|
||||
Session::put("crud.$table.answer", $answer);
|
||||
if (
|
||||
($request->filled('answer') || Session::has("crud.$table.answer"))
|
||||
&& $questionModels->count()
|
||||
&& $answerModels->count()
|
||||
) {
|
||||
$answer = $request->answer ?? Session::get("crud.$table.answer");
|
||||
Session::put("crud.$table.answer", $answer);
|
||||
|
||||
$query->whereHas('customer.answers', fn($q) => $q->whereKey($answer));
|
||||
}
|
||||
$query->whereHas('customer.answers', fn($q) => $q->whereKey($answer));
|
||||
}
|
||||
} //end if
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -371,19 +372,17 @@ class CustomerController extends Controller
|
|||
*/
|
||||
private function applySearchFilter(Request $request, Builder &$query, string $table, array $columns): void
|
||||
{
|
||||
if ($request->filled('search') || Session::has("crud.$table.search")) {
|
||||
$search = $request->search ?? Session::get("crud.$table.search");
|
||||
Session::put("crud.$table.search", $search);
|
||||
$search = $request->search ?? Session::get("crud.$table.search");
|
||||
Session::put("crud.$table.search", $search);
|
||||
|
||||
$query->where(function ($q) use ($columns, $search) {
|
||||
foreach ($columns as $column) {
|
||||
$q->orWhere($column, 'LIKE', "%$search%");
|
||||
}
|
||||
$query->where(function ($q) use ($columns, $search) {
|
||||
foreach ($columns as $column) {
|
||||
$q->orWhere($column, 'LIKE', "%$search%");
|
||||
}
|
||||
|
||||
$q->orWhere('customers.email', 'LIKE', "%$search%")
|
||||
->orWhere('customer_logins.last_connection', 'LIKE', "%$search%");
|
||||
});
|
||||
}
|
||||
$q->orWhere('customers.email', 'LIKE', "%$search%")
|
||||
->orWhere('customer_logins.last_connection', 'LIKE', "%$search%");
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ class QuestionController extends Controller
|
|||
$query->with(['brand', 'answers']);
|
||||
|
||||
/** @var \Illuminate\Pagination\AbstractPaginator */
|
||||
$questionModels = $this->paginate($query);
|
||||
$questionModels = $query->paginate($this->getPagination());
|
||||
|
||||
return view('bo.pages.questions.index', compact('questionModels', 'searchFields'));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ class ServiceController extends Controller
|
|||
|
||||
$query->with(['brand']);
|
||||
|
||||
$serviceModels = $this->paginate($query);
|
||||
$serviceModels = $query->paginate($this->getPagination());
|
||||
|
||||
return view('bo.pages.services.index', compact('serviceModels', 'searchFields'));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,20 +29,23 @@ class SingleOptinController extends Controller
|
|||
*/
|
||||
public function index(Request $request): \Illuminate\Contracts\View\View
|
||||
{
|
||||
$query = SingleOptin::query();
|
||||
$questionModels = null;
|
||||
$answerModels = null;
|
||||
$searchFields = trans('E-mail');
|
||||
|
||||
$this->applyBrandAndAnswerFilters($request, $query, $questionModels, $answerModels);
|
||||
$this->applySearch($request, $query);
|
||||
$this->sortQuery($query);
|
||||
if ($request->filled('search')) {
|
||||
$query = SingleOptin::query();
|
||||
|
||||
$query->with('brand');
|
||||
$singleoptinModels = $this->paginate($query);
|
||||
$searchFields = trans('E-mail');
|
||||
$this->applyBrandAndAnswerFilters($request, $query, $questionModels, $answerModels);
|
||||
$this->applySearch($request, $query);
|
||||
$this->sortQuery($query);
|
||||
|
||||
$query->with('brand');
|
||||
$singleoptinModels = $query->simplePaginate($this->getPagination());
|
||||
}
|
||||
|
||||
return view('bo.pages.singleoptins.index', [
|
||||
'singleoptinModels' => $singleoptinModels,
|
||||
'singleoptinModels' => $singleoptinModels ?? collect(),
|
||||
'searchFields' => $searchFields,
|
||||
'questionModels' => $questionModels,
|
||||
'answerModels' => $answerModels,
|
||||
|
|
@ -88,7 +91,7 @@ class SingleOptinController extends Controller
|
|||
?Collection &$questionModels,
|
||||
?Collection &$answerModels
|
||||
): void {
|
||||
if (!$request->filled('brand')) {
|
||||
if (!$request->filled('brand') || !(int) $request->brand) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,14 +33,14 @@ class UserController extends Controller
|
|||
*/
|
||||
public function index(Request $request): \Illuminate\Contracts\View\View
|
||||
{
|
||||
/** @var \Illuminate\Database\Eloquent\Builder $userModels */
|
||||
$userModels = User::query();
|
||||
/** @var \Illuminate\Database\Eloquent\Builder $query */
|
||||
$query = User::query();
|
||||
|
||||
/** @var string $search Search field */
|
||||
$search = $request->search;
|
||||
if ($search) {
|
||||
$this->searchQuery(
|
||||
$userModels,
|
||||
$query,
|
||||
$search,
|
||||
null,
|
||||
'first_name',
|
||||
|
|
@ -57,10 +57,10 @@ class UserController extends Controller
|
|||
]);
|
||||
|
||||
/** Sort columns with a query */
|
||||
$this->sortQuery($userModels);
|
||||
$this->sortQuery($query);
|
||||
|
||||
/** Custom pagination */
|
||||
$userModels = $this->paginate($userModels);
|
||||
$userModels = $query->paginate($this->getPagination());
|
||||
|
||||
return view('bo.pages.users.index', compact('userModels', 'search', 'searchFields'));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -189,16 +189,13 @@ class Controller extends BaseController
|
|||
}
|
||||
|
||||
/**
|
||||
* Customize pagination with cache or config (default).
|
||||
* Get the number of items per page.
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param \App\Enums\Pagination\ItemsPerPaginationEnum|null $pagination
|
||||
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
|
||||
* @return integer
|
||||
*/
|
||||
protected function paginate(
|
||||
Builder $query,
|
||||
ItemsPerPaginationEnum $pagination = null
|
||||
): \Illuminate\Contracts\Pagination\LengthAwarePaginator {
|
||||
protected function getPagination(ItemsPerPaginationEnum $pagination = null): int
|
||||
{
|
||||
$currentRoutePath = Str::slug(request()->route()->getName());
|
||||
$cacheKey = "pagination.{$currentRoutePath}";
|
||||
$pagination = $pagination ?? ItemsPerPaginationEnum::twelve;
|
||||
|
|
@ -210,8 +207,7 @@ class Controller extends BaseController
|
|||
if (Cache::get($cacheKey) !== $pagination) {
|
||||
Cache::put($cacheKey, $pagination);
|
||||
}
|
||||
$query = $query->paginate($pagination);
|
||||
return $query;
|
||||
return $pagination;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -32,7 +32,8 @@ class ViewServiceProvider extends ServiceProvider
|
|||
// * FORCE BOOTSTRAP PAGINATOR (or custom if in front)
|
||||
// Early boot, request wont be filled as expected.
|
||||
if (collect(explode('/', \request()->getPathInfo()))->get(1) === 'bo') {
|
||||
Paginator::defaultView('bo.modules.pagination');
|
||||
Paginator::defaultView('bo.modules.pagination.default');
|
||||
Paginator::defaultSimpleView('bo.modules.pagination.simple');
|
||||
} else {
|
||||
Paginator::useBootstrapFive();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ function setupFilterListener(selectId: string, paramKey: FilterKey): void {
|
|||
if (value !== "0") {
|
||||
const url = new URL(location.href);
|
||||
url.searchParams.set(paramKey, value);
|
||||
url.searchParams.set("page", "1");
|
||||
url.searchParams.delete("rstFltrs");
|
||||
url.searchParams.delete("rstSrts");
|
||||
location.assign(url.search);
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ import {
|
|||
faSyncAlt,
|
||||
faTimes,
|
||||
faTrash,
|
||||
faTriangleExclamation,
|
||||
faUndoAlt,
|
||||
faWandMagic,
|
||||
} from "@fortawesome/free-solid-svg-icons";
|
||||
|
|
@ -92,6 +93,7 @@ library.add(
|
|||
faArrowUpRightFromSquare,
|
||||
faCommentSlash,
|
||||
faCommentDots,
|
||||
faTriangleExclamation,
|
||||
);
|
||||
|
||||
// Front
|
||||
|
|
|
|||
|
|
@ -2,26 +2,7 @@
|
|||
@php $pagination = intval(Cache::get('pagination.' . str(request()->route()->getName())->slug())); @endphp
|
||||
@if ($paginator->items())
|
||||
<nav class="pagination-custom d-flex justify-content-between align-items-center">
|
||||
{{-- SELECT ITEMS PER PAGE --}}
|
||||
<div class="dropup-center d-flex justify-content-center align-items-center input-group w-fit">
|
||||
<span class="btn-md input-group-text" data-bs-tooltip="tooltip" title="{{ __('pagination.paginate_list') }}">
|
||||
<i class="fa-solid fa-list-ul"></i>
|
||||
</span>
|
||||
<button class="btn btn-primary dropdown-toggle" data-bs-toggle="dropdown" type="button" aria-expanded="false">
|
||||
{{ $pagination }}
|
||||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
@foreach (\App\Enums\Pagination\ItemsPerPaginationEnum::toArray() as $itemsPerPaginationEnum)
|
||||
<li>
|
||||
<a class="dropdown-item user-select-none @if ($pagination === $itemsPerPaginationEnum->value) active @endif text-center"
|
||||
href="{{ request()->fullUrlWithQuery(['page' => 1, 'pagination' => $itemsPerPaginationEnum->value]) }}"
|
||||
role="button">
|
||||
{{ $itemsPerPaginationEnum->value }}
|
||||
</a>
|
||||
</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
</div>
|
||||
@include('bo.modules.pagination.items-per-page')
|
||||
@if ($paginator->hasPages())
|
||||
{{-- PAGINATION --}}
|
||||
<div class="d-flex justify-content-end align-items-center">
|
||||
|
|
@ -51,15 +32,18 @@
|
|||
@if ($i >= $paginator->currentPage() - 2 && $i <= $paginator->currentPage() + 2)
|
||||
@if ($i == $paginator->currentPage())
|
||||
<li class="page-item">
|
||||
<form action="{{ route(request()->route()->getName(), request()->route()->parameters()) }}">
|
||||
<input class="form-control border-start-0 rounded-0" type="number" name="page" value="{{ $i }}"
|
||||
min="1" max="{{ $paginator->lastPage() }}">
|
||||
<form
|
||||
action="{{ route(request()->route()->getName(), request()->route()->parameters()) }}">
|
||||
<input class="form-control border-start-0 rounded-0" type="number"
|
||||
name="page" value="{{ $i }}" min="1"
|
||||
max="{{ $paginator->lastPage() }}">
|
||||
</form>
|
||||
</li>
|
||||
@else
|
||||
<li class="page-item d-none d-md-block" data-bs-tooltip="tooltip"
|
||||
title="{{ __('pagination.specific_page', ['id' => $i]) }}">
|
||||
<a class="page-link" href="{{ request()->fullUrlWithQuery(['page' => $i]) }}">{{ $i }}</a>
|
||||
<a class="page-link"
|
||||
href="{{ request()->fullUrlWithQuery(['page' => $i]) }}">{{ $i }}</a>
|
||||
</li>
|
||||
@endif
|
||||
@endif
|
||||
|
|
@ -82,7 +66,8 @@
|
|||
title="{{ __('pagination.next_page') }}" aria-label="{{ __('pagination.next_page') }}"
|
||||
@if ($paginator->hasMorePages()) href="{{ request()->fullUrlWithQuery(['page' => $paginator->currentPage() + 1]) }}" @endif
|
||||
rel="next" @if (!$paginator->hasMorePages()) aria-hidden="true" disabled @endif>
|
||||
<i class="fa-solid fa-chevron-right fa-2xs mt-1"></i></a>
|
||||
<i class="fa-solid fa-chevron-right fa-2xs mt-1"></i>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
<div class="dropup-center d-flex justify-content-center align-items-center input-group w-fit">
|
||||
<span class="btn-md input-group-text" data-bs-tooltip="tooltip" title="{{ __('pagination.paginate_list') }}">
|
||||
<i class="fa-solid fa-list-ul"></i>
|
||||
</span>
|
||||
<button class="btn btn-primary dropdown-toggle" data-bs-toggle="dropdown" type="button" aria-expanded="false">
|
||||
{{ $pagination }}
|
||||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
@foreach (\App\Enums\Pagination\ItemsPerPaginationEnum::toArray() as $itemsPerPaginationEnum)
|
||||
<li>
|
||||
<a class="dropdown-item user-select-none @if ($pagination === $itemsPerPaginationEnum->value) active @endif text-center"
|
||||
href="{{ request()->fullUrlWithQuery(['page' => 1, 'pagination' => $itemsPerPaginationEnum->value]) }}"
|
||||
role="button">
|
||||
{{ $itemsPerPaginationEnum->value }}
|
||||
</a>
|
||||
</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
</div>
|
||||
32
resources/views/bo/modules/pagination/simple.blade.php
Normal file
32
resources/views/bo/modules/pagination/simple.blade.php
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
{{-- GET ACTUAL PAGINATION --}}
|
||||
@php $pagination = intval(Cache::get('pagination.' . str(request()->route()->getName())->slug())); @endphp
|
||||
@if ($paginator->items())
|
||||
<nav class="pagination-custom d-flex flex-column flex-md-row justify-content-between align-items-center">
|
||||
@include('bo.modules.pagination.items-per-page')
|
||||
@if ($paginator->hasPages())
|
||||
<div class="d-flex justify-content-end align-items-center mt-2 mt-md-0">
|
||||
<ul class="pagination m-0">
|
||||
{{-- PREVIOUS PAGE --}}
|
||||
<li class="page-item @if ($paginator->onFirstPage()) disabled @endif">
|
||||
<a class="page-link d-flex align-items-center text-start h-100" data-bs-tooltip="tooltip"
|
||||
title="{{ __('pagination.previous_page') }}" aria-label="{{ __('pagination.previous_page') }}"
|
||||
@if (!$paginator->onFirstPage()) href="{{ request()->fullUrlWithQuery(['page' => $paginator->currentPage() - 1]) }}" @endif
|
||||
rel="prev" @if ($paginator->onFirstPage()) aria-hidden="true" disabled @endif>
|
||||
<i class="fa-solid fa-chevron-left fa-2xs mt-1"></i>
|
||||
<span class="ms-2">{{ __('pagination.previous_page') }}</span>
|
||||
</a>
|
||||
</li>
|
||||
{{-- NEXT PAGE --}}
|
||||
<li class="page-item @if (!$paginator->hasMorePages()) disabled @endif">
|
||||
<a class="page-link d-flex align-items-center text-end h-100" data-bs-tooltip="tooltip"
|
||||
title="{{ __('pagination.next_page') }}" aria-label="{{ __('pagination.next_page') }}"
|
||||
@if ($paginator->hasMorePages()) href="{{ request()->fullUrlWithQuery(['page' => $paginator->currentPage() + 1]) }}" @endif
|
||||
rel="next" @if (!$paginator->hasMorePages()) aria-hidden="true" disabled @endif>
|
||||
<span class="me-2">{{ __('pagination.next_page') }}</span>
|
||||
<i class="fa-solid fa-chevron-right fa-2xs mt-1"></i>
|
||||
</a>
|
||||
</li>
|
||||
</div>
|
||||
@endif
|
||||
</nav>
|
||||
@endif
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
<div class="col-12 col-lg-6">
|
||||
{{-- BRAND SELECT --}}
|
||||
<select class="form-select mb-1 {{ $routeCondition && $selectedBrand && $questionModels ? 'mb-lg-1' : 'mb-lg-0' }}"
|
||||
id="brandSelect" role="button">
|
||||
id="brandSelect" role="button" name="brand">
|
||||
<option value="0" @selected(!$selectedBrand)>{{ __('Sélectionnez une marque...') }}</option>
|
||||
@foreach (\App\Models\Brand::getUserAssociatedBrands() as $brand)
|
||||
<option value="{{ $brand->getKey() }}" @selected($selectedBrand == $brand->getKey())>
|
||||
|
|
@ -27,8 +27,9 @@
|
|||
</select>
|
||||
|
||||
{{-- QUESTION SELECT --}}
|
||||
@if ($routeCondition && $selectedBrand && $questionModels->count())
|
||||
<select id="questionSelect" role="button" class="form-select mb-1 {{ $selectedQuestion && $answerModels ? 'mb-lg-1' : 'mb-lg-0' }}">
|
||||
@if ($routeCondition && $selectedBrand && isset($questionModels) && !$questionModels->isEmpty())
|
||||
<select id="questionSelect" role="button" class="form-select mb-1 {{ $selectedQuestion && $answerModels ? 'mb-lg-1' : 'mb-lg-0' }}"
|
||||
name="question">
|
||||
<option value="0" @selected(!$selectedQuestion)>{{ __('Sélectionnez une question...') }}</option>
|
||||
@foreach ($questionModels as $question)
|
||||
<option value="{{ $question->getKey() }}" @selected($selectedQuestion == $question->getKey())>
|
||||
|
|
@ -39,8 +40,8 @@
|
|||
@endif
|
||||
|
||||
{{-- ANSWER SELECT --}}
|
||||
@if ($routeCondition && $selectedQuestion && $questionModels->count() && $answerModels->count())
|
||||
<select id="answerSelect" class="form-select mb-1 mb-lg-0" role="button">
|
||||
@if ($routeCondition && $selectedQuestion && isset($questionModels) && !$questionModels->isEmpty() && isset($answerModels) && !$answerModels->isEmpty())
|
||||
<select id="answerSelect" class="form-select mb-1 mb-lg-0" role="button" name="answer">
|
||||
<option value="0" @selected(!$selectedAnswer)>{{ __('Sélectionnez une réponse...') }}</option>
|
||||
@foreach ($answerModels as $answer)
|
||||
<option value="{{ $answer->getKey() }}" @selected($selectedAnswer == $answer->getKey())>
|
||||
|
|
@ -55,23 +56,7 @@
|
|||
<div class="input-group">
|
||||
{{-- SEARCH FIELD --}}
|
||||
<label class="input-group-text" for="searchField">{{ str($searchFields)->ucfirst() }}</label>
|
||||
<input class="form-control" id="searchField" name="search" type="search" value="{{ $search }}"
|
||||
placeholder="Recherche.." />
|
||||
|
||||
{{-- HIDDEN INPUTS --}}
|
||||
<input type="hidden" name="sort_col" type="text" value="{{ $sortCol }}">
|
||||
<input type="hidden" name="sort_way" type="text" value="{{ $sortWay }}">
|
||||
@php
|
||||
$parameters = ['brand' => $selectedBrand];
|
||||
if ($routes) {
|
||||
$parameters = array_merge($parameters, ['question' => $selectedQuestion, 'answer' => $selectedAnswer]);
|
||||
}
|
||||
@endphp
|
||||
@foreach ($parameters as $key => $val)
|
||||
@if ($val)
|
||||
<input type="hidden" name="{{ $key }}" type="text" value="{{ $val }}">
|
||||
@endif
|
||||
@endforeach
|
||||
<input class="form-control" id="searchField" name="search" type="search" value="{{ $search }}" placeholder="Recherche.." />
|
||||
|
||||
{{-- ACTION BUTTONS --}}
|
||||
<button class="btn btn-primary" data-bs-tooltip="tooltip" type="submit"
|
||||
|
|
@ -80,7 +65,7 @@
|
|||
</button>
|
||||
</div>
|
||||
@php
|
||||
$parameters = ['rstFltrs' => 'true', 'search' => null];
|
||||
$parameters = ['rstFltrs' => 'true', 'search' => null, 'page' => null];
|
||||
if ($routes) {
|
||||
$parameters = array_merge($parameters, ['brand' => null, 'question' => null, 'answer' => null]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,12 +17,19 @@
|
|||
</div>
|
||||
<div class="card-body">
|
||||
@include('bo.modules.search-bar')
|
||||
<div class="row w-100 mx-auto mb-2">
|
||||
<div class="col table-responsive p-0">
|
||||
@include('bo.pages.customers.index-list')
|
||||
@if (request()->filled('search') || session()->get("crud.$modelTable.search"))
|
||||
<div class="row w-100 mx-auto mb-2">
|
||||
<div class="col table-responsive p-0">
|
||||
@include('bo.pages.customers.index-list')
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{!! $customerModels->links() !!}
|
||||
{!! $customerModels->links() !!}
|
||||
@else
|
||||
<div class="d-flex flex-column justify-content-center align-items-center w-100 pt-2">
|
||||
<i class="fa-solid fa-triangle-exclamation fa-2xl"></i>
|
||||
<p class="m-0">{{ __('Veuillez faire une recherche en sélectionnant ou non une marque') }}</p>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -17,12 +17,19 @@
|
|||
</div>
|
||||
<div class="card-body">
|
||||
@include('bo.modules.search-bar')
|
||||
<div class="row w-100 mx-auto mb-2">
|
||||
<div class="col table-responsive p-0">
|
||||
@include('bo.pages.singleoptins.index-list')
|
||||
@if (request()->filled('search'))
|
||||
<div class="row w-100 mx-auto mb-2">
|
||||
<div class="col table-responsive p-0">
|
||||
@include('bo.pages.singleoptins.index-list')
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{!! $singleoptinModels->links() !!}
|
||||
{!! $singleoptinModels->links() !!}
|
||||
@else
|
||||
<div class="d-flex flex-column justify-content-center align-items-center w-100 pt-2">
|
||||
<i class="fa-solid fa-triangle-exclamation fa-2xl"></i>
|
||||
<p class="m-0">{{ __('Veuillez faire une recherche en sélectionnant ou non une marque') }}</p>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue