移除 大搜尋 20250502
This commit is contained in:
parent
0616629499
commit
c2aaff1f30
108
app/Livewire/Admin/BranchesTable.php
Normal file
108
app/Livewire/Admin/BranchesTable.php
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Livewire\Admin;
|
||||||
|
|
||||||
|
use App\Models\Branches;
|
||||||
|
use Illuminate\Support\Carbon;
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use PowerComponents\LivewirePowerGrid\Button;
|
||||||
|
use PowerComponents\LivewirePowerGrid\Column;
|
||||||
|
use PowerComponents\LivewirePowerGrid\Facades\Filter;
|
||||||
|
use PowerComponents\LivewirePowerGrid\Facades\PowerGrid;
|
||||||
|
use PowerComponents\LivewirePowerGrid\PowerGridFields;
|
||||||
|
use PowerComponents\LivewirePowerGrid\PowerGridComponent;
|
||||||
|
|
||||||
|
final class BranchesTable extends PowerGridComponent
|
||||||
|
{
|
||||||
|
public string $tableName = 'branches-table-lcqb7y-table';
|
||||||
|
|
||||||
|
public function setUp(): array
|
||||||
|
{
|
||||||
|
$this->showCheckBox();
|
||||||
|
|
||||||
|
return [
|
||||||
|
PowerGrid::header()
|
||||||
|
->showSearchInput(),
|
||||||
|
PowerGrid::footer()
|
||||||
|
->showPerPage()
|
||||||
|
->showRecordCount(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function datasource(): Builder
|
||||||
|
{
|
||||||
|
return Branches::query();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function relationSearch(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function fields(): PowerGridFields
|
||||||
|
{
|
||||||
|
return PowerGrid::fields()
|
||||||
|
->add('id')
|
||||||
|
->add('name')
|
||||||
|
->add('external_ip')
|
||||||
|
->add('created_at');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function columns(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
Column::make('Id', 'id'),
|
||||||
|
Column::make('Name', 'name')
|
||||||
|
->sortable()
|
||||||
|
->searchable(),
|
||||||
|
|
||||||
|
Column::make('External ip', 'external_ip')
|
||||||
|
->sortable()
|
||||||
|
->searchable(),
|
||||||
|
|
||||||
|
Column::make('Created at', 'created_at_formatted', 'created_at')
|
||||||
|
->sortable(),
|
||||||
|
|
||||||
|
Column::make('Created at', 'created_at')
|
||||||
|
->sortable()
|
||||||
|
->searchable(),
|
||||||
|
|
||||||
|
Column::action('Action')
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function filters(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
#[\Livewire\Attributes\On('edit')]
|
||||||
|
public function edit($rowId): void
|
||||||
|
{
|
||||||
|
$this->js('alert('.$rowId.')');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function actions(Branches $row): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
Button::add('edit')
|
||||||
|
->slot('Edit: '.$row->id)
|
||||||
|
->id()
|
||||||
|
->class('pg-btn-white dark:ring-pg-primary-600 dark:border-pg-primary-600 dark:hover:bg-pg-primary-700 dark:ring-offset-pg-primary-800 dark:text-pg-primary-300 dark:bg-pg-primary-700')
|
||||||
|
->dispatch('edit', ['rowId' => $row->id])
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
public function actionRules($row): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
// Hide button edit for ID 1
|
||||||
|
Rule::button('edit')
|
||||||
|
->when(fn($row) => $row->id === 1)
|
||||||
|
->hide(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
@ -3,6 +3,7 @@
|
|||||||
namespace App\Livewire\Admin;
|
namespace App\Livewire\Admin;
|
||||||
|
|
||||||
use Spatie\Permission\Models\Role;
|
use Spatie\Permission\Models\Role;
|
||||||
|
use Spatie\Permission\Models\Permission;
|
||||||
use Illuminate\Support\Carbon;
|
use Illuminate\Support\Carbon;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use PowerComponents\LivewirePowerGrid\Button;
|
use PowerComponents\LivewirePowerGrid\Button;
|
||||||
@ -47,10 +48,19 @@ final class RoleTable extends PowerGridComponent
|
|||||||
|
|
||||||
public function fields(): PowerGridFields
|
public function fields(): PowerGridFields
|
||||||
{
|
{
|
||||||
|
$allPermissions = Permission::pluck('name')->sort()->values();
|
||||||
return PowerGrid::fields()
|
return PowerGrid::fields()
|
||||||
->add('id')
|
->add('id')
|
||||||
->add('name')
|
->add('name')
|
||||||
->add('permissions_list' ,fn(Role $model)=> $model->permissions->pluck('name')->implode(', '))
|
->add('permissions_list', function (Role $model) use ($allPermissions) {
|
||||||
|
$rolePermissions = $model->permissions->pluck('name')->sort()->values();
|
||||||
|
|
||||||
|
if ($rolePermissions->count() === $allPermissions->count() && $rolePermissions->values()->all() === $allPermissions->values()->all()) {
|
||||||
|
return 'all';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $rolePermissions->implode(', ');
|
||||||
|
})
|
||||||
->add('created_at_formatted', fn (Role $model) => Carbon::parse($model->created_at)->format('d/m/Y H:i:s'));
|
->add('created_at_formatted', fn (Role $model) => Carbon::parse($model->created_at)->format('d/m/Y H:i:s'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
124
app/Livewire/Admin/RoomsTable.php
Normal file
124
app/Livewire/Admin/RoomsTable.php
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Livewire\Admin;
|
||||||
|
|
||||||
|
use App\Models\Rooms;
|
||||||
|
use Illuminate\Support\Carbon;
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use PowerComponents\LivewirePowerGrid\Button;
|
||||||
|
use PowerComponents\LivewirePowerGrid\Column;
|
||||||
|
use PowerComponents\LivewirePowerGrid\Facades\Filter;
|
||||||
|
use PowerComponents\LivewirePowerGrid\Facades\PowerGrid;
|
||||||
|
use PowerComponents\LivewirePowerGrid\PowerGridFields;
|
||||||
|
use PowerComponents\LivewirePowerGrid\PowerGridComponent;
|
||||||
|
|
||||||
|
final class RoomsTable extends PowerGridComponent
|
||||||
|
{
|
||||||
|
public string $tableName = 'rooms-table-tsjlhj-table';
|
||||||
|
|
||||||
|
public function setUp(): array
|
||||||
|
{
|
||||||
|
$this->showCheckBox();
|
||||||
|
|
||||||
|
return [
|
||||||
|
PowerGrid::header()
|
||||||
|
->showSearchInput(),
|
||||||
|
PowerGrid::footer()
|
||||||
|
->showPerPage()
|
||||||
|
->showRecordCount(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function datasource(): Builder
|
||||||
|
{
|
||||||
|
return Rooms::query();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function relationSearch(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function fields(): PowerGridFields
|
||||||
|
{
|
||||||
|
return PowerGrid::fields()
|
||||||
|
->add('id')
|
||||||
|
->add('branch_id')
|
||||||
|
->add('name')
|
||||||
|
->add('internal_ip')
|
||||||
|
->add('port')
|
||||||
|
->add('status')
|
||||||
|
->add('started_at_formatted', fn (Rooms $model) => Carbon::parse($model->started_at)->format('d/m/Y H:i:s'))
|
||||||
|
->add('ended_at_formatted', fn (Rooms $model) => Carbon::parse($model->ended_at)->format('d/m/Y H:i:s'))
|
||||||
|
->add('created_at_formatted', fn (Rooms $model) => Carbon::parse($model->created_at)->format('d/m/Y H:i:s'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function columns(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
Column::make('Id', 'id'),
|
||||||
|
Column::make('Branch id', 'branch_id'),
|
||||||
|
Column::make('Name', 'name')
|
||||||
|
->sortable()
|
||||||
|
->searchable(),
|
||||||
|
|
||||||
|
Column::make('Internal ip', 'internal_ip')
|
||||||
|
->sortable()
|
||||||
|
->searchable(),
|
||||||
|
|
||||||
|
Column::make('Port', 'port'),
|
||||||
|
Column::make('Status', 'status')
|
||||||
|
->sortable()
|
||||||
|
->searchable(),
|
||||||
|
|
||||||
|
Column::make('Started at', 'started_at_formatted', 'started_at')
|
||||||
|
->sortable(),
|
||||||
|
|
||||||
|
Column::make('Ended at', 'ended_at_formatted', 'ended_at')
|
||||||
|
->sortable(),
|
||||||
|
|
||||||
|
Column::make('Created at', 'created_at_formatted', 'created_at')
|
||||||
|
->sortable(),
|
||||||
|
|
||||||
|
Column::action('Action')
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function filters(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
Filter::datetimepicker('started_at'),
|
||||||
|
Filter::datetimepicker('ended_at'),
|
||||||
|
Filter::datetimepicker('created_at'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
#[\Livewire\Attributes\On('edit')]
|
||||||
|
public function edit($rowId): void
|
||||||
|
{
|
||||||
|
$this->js('alert('.$rowId.')');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function actions(Rooms $row): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
Button::add('edit')
|
||||||
|
->slot('Edit: '.$row->id)
|
||||||
|
->id()
|
||||||
|
->class('pg-btn-white dark:ring-pg-primary-600 dark:border-pg-primary-600 dark:hover:bg-pg-primary-700 dark:ring-offset-pg-primary-800 dark:text-pg-primary-300 dark:bg-pg-primary-700')
|
||||||
|
->dispatch('edit', ['rowId' => $row->id])
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
public function actionRules($row): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
// Hide button edit for ID 1
|
||||||
|
Rule::button('edit')
|
||||||
|
->when(fn($row) => $row->id === 1)
|
||||||
|
->hide(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
@ -43,7 +43,8 @@ final class SongTable extends PowerGridComponent
|
|||||||
PowerGrid::header()
|
PowerGrid::header()
|
||||||
->showSoftDeletes()
|
->showSoftDeletes()
|
||||||
->showToggleColumns()
|
->showToggleColumns()
|
||||||
->showSearchInput(),
|
//->showSearchInput()
|
||||||
|
,
|
||||||
PowerGrid::footer()
|
PowerGrid::footer()
|
||||||
->showPerPage()
|
->showPerPage()
|
||||||
->showRecordCount(),
|
->showRecordCount(),
|
||||||
|
@ -42,7 +42,8 @@ final class UserTable extends PowerGridComponent
|
|||||||
PowerGrid::header()
|
PowerGrid::header()
|
||||||
//->showSoftDeletes()
|
//->showSoftDeletes()
|
||||||
->showToggleColumns()
|
->showToggleColumns()
|
||||||
->showSearchInput(),
|
//->showSearchInput()
|
||||||
|
,
|
||||||
PowerGrid::footer()->showPerPage()->showRecordCount(),
|
PowerGrid::footer()->showPerPage()->showRecordCount(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user