47 lines
1.6 KiB
PHP
47 lines
1.6 KiB
PHP
@php
|
|
/** @var string $route */
|
|
/** @var \Illuminate\Database\Eloquent\Model $model */
|
|
/** @var bool $first */
|
|
/** @var bool $last */
|
|
|
|
// * Route vars
|
|
$routeName = request()->route()?->getName() ?? 'noroute';
|
|
|
|
// * Request vars
|
|
$currentSortCol = session()->get("{$routeName}.sort_col");
|
|
$currentSortWay = session()->get("{$routeName}.sort_way");
|
|
|
|
$searchQuery = request()->input('search');
|
|
|
|
// * Vue vars
|
|
$noOrder = $noOrder ?? false;
|
|
$ignore = isset($ignore) && is_array($ignore) ? $ignore : [];
|
|
|
|
// * Hide order column
|
|
$sortColIsOrder = $currentSortCol === 'order';
|
|
$noOrder = $noOrder || (!$sortColIsOrder && $currentSortCol) || !empty($searchQuery);
|
|
View::share('noOrder', $noOrder);
|
|
|
|
// * Reset button
|
|
$hasCustomSort = ($currentSortCol && $currentSortCol !== 'order') || ($currentSortCol === 'order' && $currentSortWay === 'desc');
|
|
$showReset = !empty($searchQuery) || $hasCustomSort;
|
|
@endphp
|
|
@if (!$noOrder)
|
|
<td>
|
|
<form method="POST">
|
|
@csrf
|
|
@method('PATCH')
|
|
<input name="action" type="hidden" value="down">
|
|
@if (!$first)
|
|
<button class="btn btn-link text-decoration-none" formaction="{{ route($route, [$model, 'action' => 'up']) }}" type="submit">
|
|
<i class="icon-size fas fa-arrow-alt-circle-up fa-2x" name="down_up"></i>
|
|
</button>
|
|
@endif
|
|
@if (!$last)
|
|
<button class="btn btn-link text-decoration-none" formaction="{{ route($route, [$model, 'action' => 'down']) }}" type="submit">
|
|
<i class="icon-size fas fa-arrow-alt-circle-down fa-2x" name="down_arrow"></i>
|
|
</button>
|
|
@endif
|
|
</form>
|
|
@endif
|
|
</td>
|