78 lines
2.2 KiB
PHP
78 lines
2.2 KiB
PHP
<?php
|
|
|
|
namespace App\Livewire;
|
|
|
|
use App\Models\UserNote;
|
|
use Filament\Actions\Concerns\InteractsWithActions;
|
|
use Filament\Actions\Contracts\HasActions;
|
|
use Filament\Forms\Components\Textarea;
|
|
use Filament\Schemas\Concerns\InteractsWithSchemas;
|
|
use Filament\Schemas\Contracts\HasSchemas;
|
|
use Filament\Schemas\Schema;
|
|
use Filament\Tables\Columns\TextColumn;
|
|
use Filament\Tables\Concerns\InteractsWithTable;
|
|
use Filament\Tables\Contracts\HasTable;
|
|
use Filament\Tables\Table;
|
|
use Illuminate\Contracts\View\View;
|
|
use Livewire\Component;
|
|
|
|
class EditUserNote extends Component implements HasActions, HasSchemas, HasTable
|
|
{
|
|
use InteractsWithActions;
|
|
use InteractsWithSchemas;
|
|
use InteractsWithTable;
|
|
|
|
public $record;
|
|
|
|
public ?array $data = [];
|
|
|
|
public function mount($record)
|
|
{
|
|
$this->record = $record;
|
|
}
|
|
|
|
public function form(Schema $schema): Schema
|
|
{
|
|
return $schema
|
|
->components([
|
|
Textarea::make('message')->required()->rows(2)->label('Add a new note'),
|
|
])
|
|
->statePath('data');
|
|
}
|
|
|
|
public function create(): void
|
|
{
|
|
dd($this->form->getState());
|
|
}
|
|
|
|
public function table(Table $table): Table
|
|
{
|
|
return $table
|
|
// ->headerActions([
|
|
// Action::make()
|
|
// ->label('New note')
|
|
// ->icon('phosphor-plus')
|
|
// ->action(function () {
|
|
// UserNote::insert(['event_id' => $this->record->id, 'bookmaker_id' => auth()->user()->bookmaker_id, 'user_id' => auth()->user()->id]);
|
|
// }),
|
|
// ])
|
|
->query(UserNote::query()->where('event_id', $this->record->id)->where('bookmaker_id', auth()->user()->bookmaker_id)->where('user_id', auth()->user()->id))
|
|
->columns([
|
|
TextColumn::make('message')->label('Notes'),
|
|
])
|
|
->filters([
|
|
// ...
|
|
])
|
|
->recordActions([
|
|
// ...
|
|
])
|
|
->toolbarActions([
|
|
]);
|
|
}
|
|
|
|
public function render(): View
|
|
{
|
|
return view('livewire.edit-user-note');
|
|
}
|
|
}
|