mirror of
https://github.com/HolgerHatGarKeineNode/einundzwanzig-nostr.git
synced 2025-12-13 05:26:47 +00:00
first copies from portal
This commit is contained in:
97
app/Livewire/MeetupTable.php
Normal file
97
app/Livewire/MeetupTable.php
Normal file
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use App\Models\Meetup;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Carbon;
|
||||
use PowerComponents\LivewirePowerGrid\Button;
|
||||
use PowerComponents\LivewirePowerGrid\Column;
|
||||
use PowerComponents\LivewirePowerGrid\Exportable;
|
||||
use PowerComponents\LivewirePowerGrid\Facades\Filter;
|
||||
use PowerComponents\LivewirePowerGrid\Facades\Rule;
|
||||
use PowerComponents\LivewirePowerGrid\Footer;
|
||||
use PowerComponents\LivewirePowerGrid\Header;
|
||||
use PowerComponents\LivewirePowerGrid\Lazy;
|
||||
use PowerComponents\LivewirePowerGrid\PowerGrid;
|
||||
use PowerComponents\LivewirePowerGrid\PowerGridFields;
|
||||
use PowerComponents\LivewirePowerGrid\PowerGridComponent;
|
||||
|
||||
final class MeetupTable extends PowerGridComponent
|
||||
{
|
||||
public function setUp(): array
|
||||
{
|
||||
$this->showCheckBox();
|
||||
|
||||
return [
|
||||
Exportable::make('export')
|
||||
->striped()
|
||||
->type(Exportable::TYPE_XLS, Exportable::TYPE_CSV),
|
||||
Footer::make()
|
||||
->showPerPage(perPage: 25)
|
||||
->showRecordCount(),
|
||||
];
|
||||
}
|
||||
|
||||
public function datasource(): Builder
|
||||
{
|
||||
return Meetup::query();
|
||||
}
|
||||
|
||||
public function fields(): PowerGridFields
|
||||
{
|
||||
return PowerGrid::fields()
|
||||
->add('name')
|
||||
->add('name_lower', fn (Meetup $model) => strtolower(e($model->name)))
|
||||
->add('created_at')
|
||||
->add('created_at_formatted', fn (Meetup $model) => Carbon::parse($model->created_at)->format('d/m/Y H:i:s'));
|
||||
}
|
||||
|
||||
public function columns(): array
|
||||
{
|
||||
return [
|
||||
Column::make('Name', 'name')
|
||||
->searchable()
|
||||
->sortable(),
|
||||
|
||||
Column::action('Action')
|
||||
];
|
||||
}
|
||||
|
||||
public function filters(): array
|
||||
{
|
||||
return [
|
||||
Filter::inputText('name'),
|
||||
Filter::datepicker('created_at_formatted', 'created_at'),
|
||||
];
|
||||
}
|
||||
|
||||
#[\Livewire\Attributes\On('edit')]
|
||||
public function edit($rowId): void
|
||||
{
|
||||
$this->js('alert('.$rowId.')');
|
||||
}
|
||||
|
||||
public function actions(Meetup $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(Meetup $row): array
|
||||
{
|
||||
return [
|
||||
// Hide button edit for ID 1
|
||||
Rule::button('edit')
|
||||
->when(fn($row) => $row->id === 1)
|
||||
->hide(),
|
||||
];
|
||||
}
|
||||
*/
|
||||
}
|
||||
Reference in New Issue
Block a user