83 lines
2.5 KiB
PHP
83 lines
2.5 KiB
PHP
|
<?php
|
||
|
|
||
|
namespace App\Livewire\Forms;
|
||
|
|
||
|
use App\Models\RoomStatusLog;
|
||
|
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 RoomStatusLogTable extends PowerGridComponent
|
||
|
{
|
||
|
public string $tableName = 'room-status-log-table';
|
||
|
|
||
|
public bool $showFilters = false;
|
||
|
public function boot(): void
|
||
|
{
|
||
|
config(['livewire-powergrid.filter' => 'outside']);
|
||
|
}
|
||
|
|
||
|
public function setUp(): array
|
||
|
{
|
||
|
$actions = [];
|
||
|
$header = PowerGrid::header()
|
||
|
->withoutLoading()
|
||
|
->showToggleColumns();
|
||
|
$header->includeViewOnTop('livewire.header.admin.room-status-log');
|
||
|
|
||
|
$actions[]=$header;
|
||
|
$actions[]=PowerGrid::footer()->showPerPage()->showRecordCount();
|
||
|
return $actions;
|
||
|
}
|
||
|
|
||
|
public function datasource(): Builder
|
||
|
{
|
||
|
return RoomStatusLog::query()->latest();;
|
||
|
}
|
||
|
|
||
|
public function relationSearch(): array
|
||
|
{
|
||
|
return [];
|
||
|
}
|
||
|
|
||
|
public function fields(): PowerGridFields
|
||
|
{
|
||
|
return PowerGrid::fields()
|
||
|
->add('id')
|
||
|
->add('room_name', function (RoomStatusLog $model) {
|
||
|
return $model->room?->type->labelPowergridFilter().$model->room?->name;
|
||
|
})
|
||
|
->add('user_name', function (RoomStatusLog $model){
|
||
|
return $model->user?->name;
|
||
|
})
|
||
|
->add('status_str',function (RoomStatusLog $model){
|
||
|
return $model->status->labelPowergridFilter();
|
||
|
})
|
||
|
->add('message')
|
||
|
->add('created_at');
|
||
|
}
|
||
|
|
||
|
public function columns(): array
|
||
|
{
|
||
|
$column=[];
|
||
|
$column[]=Column::make(__('room-status-log.id'), 'id');
|
||
|
$column[]=Column::make(__('room-status-log.room'), 'room_name');
|
||
|
$column[]=Column::make(__('room-status-log.user'), 'user_name');
|
||
|
$column[]=Column::make(__('room-status-log.status'), 'status_str');
|
||
|
$column[]=Column::make(__('room-status-log.message'), 'message');
|
||
|
$column[]=Column::make(__('room-status-log.created_at'), 'created_at');
|
||
|
return $column;
|
||
|
}
|
||
|
|
||
|
public function filters(): array
|
||
|
{
|
||
|
return [
|
||
|
];
|
||
|
}
|
||
|
}
|