You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
use Spatie\Activitylog\Models\Activity;
use Illuminate\Support\Carbon;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Facades\Auth;
use PowerComponents\LivewirePowerGrid\Button;
use PowerComponents\LivewirePowerGrid\Column;
use PowerComponents\LivewirePowerGrid\Exportable;
use PowerComponents\LivewirePowerGrid\Facades\Filter;
use PowerComponents\LivewirePowerGrid\Footer;
use PowerComponents\LivewirePowerGrid\Header;
use PowerComponents\LivewirePowerGrid\PowerGrid;
use PowerComponents\LivewirePowerGrid\PowerGridFields;
use PowerComponents\LivewirePowerGrid\PowerGridComponent;
use PowerComponents\LivewirePowerGrid\Responsive;
use PowerComponents\LivewirePowerGrid\Traits\WithExport;
final class ActivityTable extends PowerGridComponent
{
use WithExport;
// public bool $filtersOutside = false;
public function setUp(): array
{
$this->showCheckBox();
return [
Header::make()->showSearchInput()->showToggleColumns(),
Footer::make()
->showPerPage()
->showRecordCount(),
Responsive::make()->fixedColumns('id','event','causer_id','created_at')
];
}
public function datasource(): Builder
{
if(Auth::user()->isAdmin){
return Activity::query()->with('subject')->where('activity_log.pharmacy_id',Auth::user()->pharmacy_id)
->join('users','users.id','=','activity_log.causer_id')
->select('activity_log.*','users.firstname','users.lastname');
}
return Auth::user()->actions;
}
public function relationSearch(): array
{
return [];
}
public function fields(): PowerGridFields
{
return PowerGrid::fields()
->add('id')
->add('event')
->add('causer_id')
->add('subject_id')
->add('description')
->add('created_at')
->add('properties');
}
public function columns(): array
{
return [
Column::make('ID','id')
->sortable()
->searchable(),
Column::make('Event','event')
->sortable()
->searchable(),
Column::make('Caused By','firstname')
->sortable()
->searchable(),
Column::make('Performed On','subject.created_at')
->sortable()
->searchable(),
Column::make('Description','description')
->sortable()
->searchable(),
Column::make('Properties','properties')
->sortable()
->searchable(),
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(Activity $row): array
// {
// return [
// Button::add('view')
// ->slot("<i class='bi bi-eye-fill text-blue-600'></i>")
// ->id()
// ->class('')
// ->dispatch('myaction', ['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(),
];
}
*/
}
`
Collapse icon does not appear on first page load. Appears when sort icon on column is clicked
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
This is my code
`<?php
namespace App\Livewire;
use Spatie\Activitylog\Models\Activity;
use Illuminate\Support\Carbon;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Facades\Auth;
use PowerComponents\LivewirePowerGrid\Button;
use PowerComponents\LivewirePowerGrid\Column;
use PowerComponents\LivewirePowerGrid\Exportable;
use PowerComponents\LivewirePowerGrid\Facades\Filter;
use PowerComponents\LivewirePowerGrid\Footer;
use PowerComponents\LivewirePowerGrid\Header;
use PowerComponents\LivewirePowerGrid\PowerGrid;
use PowerComponents\LivewirePowerGrid\PowerGridFields;
use PowerComponents\LivewirePowerGrid\PowerGridComponent;
use PowerComponents\LivewirePowerGrid\Responsive;
use PowerComponents\LivewirePowerGrid\Traits\WithExport;
final class ActivityTable extends PowerGridComponent
{
use WithExport;
}
`
Collapse icon does not appear on first page load. Appears when sort icon on column is clicked
Beta Was this translation helpful? Give feedback.
All reactions