This commit is contained in:
salam committed 2026-01-30 19:08:14 +01:00
1 parent 6f40d5df30
commit 8d347aeba7
8 files changed
+114 -44

No files matched your search

@@ -23,14 +23,9 @@ use Filament\Actions\ActionGroup;
use Filament\Actions\BulkActionGroup;
use Filament\Actions\DeleteAction;
use Filament\Actions\DeleteBulkAction;
use Filament\Actions\EditAction;
use Filament\Forms\Components\Checkbox;
use Filament\Forms\Components\Hidden;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Infolists\Components\TextEntry;
use Filament\Schemas\Components\Grid;
use Filament\Schemas\Components\Section;
use Filament\Schemas\Components\Utilities\Get;
use Filament\Support\Enums\FontWeight;
use Filament\Support\Enums\VerticalAlignment;
@@ -40,6 +35,7 @@ use Filament\Tables\Enums\FiltersLayout;
use Filament\Tables\Filters\Filter;
use Filament\Tables\Filters\Indicator;
use Filament\Tables\Table;
use Illuminate\Contracts\View\View;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\DB;
@@ -66,7 +62,7 @@ class EventsTable
->poll('10s')
->striped()
->deferLoading()
->defaultPaginationPageOption(5)
->defaultPaginationPageOption(50)
->paginated([5, 10, 15])
->columns([
IconColumn::make('sport.icon')
@@ -515,30 +511,16 @@ class EventsTable
->emptyStateDescription('Modify the filter')
->recordActions([
Action::make('note')
// ->before(fn () => $this->pollingInterval = null)
// ->after(fn () => $this->pollingInterval = '1s')
->iconButton()->icon('phosphor-note')->color('gray')
->tooltip('Add a note')
->schema([
Grid::make(2)
->schema([
Section::make('Details')
->schema([
TextInput::make('name'),
Select::make('position')
->options([
'developer' => 'Developer',
'designer' => 'Designer',
]),
Checkbox::make('is_admin'),
]),
Section::make('Auditing')
->schema([
TextEntry::make('created_at')
->dateTime(),
TextEntry::make('updated_at')
->dateTime(),
]),
]),
]),
->modalSubmitAction(false)
->modalCancelAction(fn (Action $action) => $action->label('Close'))
->modalContent(fn ($record): View => view(
'filament.tables.columns.make-note',
['record' => $record],
)),
Action::make('notify')->iconButton()->icon('phosphor-bell')->color('gray')->tooltip('Add a notifications'),
Action::make('star')
->iconButton()
+77
View File
@@ -0,0 +1,77 @@
<?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');
}
}
@@ -4,7 +4,7 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Message extends Model
class UserNote extends Model
{
protected $fillable = [
'event_id',
@@ -11,7 +11,7 @@ return new class extends Migration
*/
public function up(): void
{
Schema::create('messages', function (Blueprint $table) {
Schema::create('user_notes', function (Blueprint $table) {
$table->id();
$table->foreignId('event_id')->index()->constrained()->cascadeOnDelete()->references('id')->on('events');
$table->integer('bookmaker_id')->default(0);
@@ -27,6 +27,6 @@ return new class extends Migration
*/
public function down(): void
{
Schema::dropIfExists('messages');
Schema::dropIfExists('user_notes');
}
};
-4
View File
@@ -17,10 +17,6 @@ button[wire\:click="resetTableFiltersForm"] {
/* background-color: #0f172b; */
}
.fi-ta-content-ctn {
min-height: 350px;
}
/* .fi-ta-header-toolbar {
@apply flex-row-reverse;
} */
@@ -0,0 +1,3 @@
<div>
@livewire('edit-user-note', ['record' => $record])
</div>
@@ -6,19 +6,23 @@
<div class="my-auto flex flex-col gap-4">
<div x-data="{ pop: '{{ $str }}' }">
<template x-ref="template">
<p x-html="pop" class="z-1000"></p>
<p x-html="pop"></p>
</template>
<x-filament::icon-button icon="phosphor-chat-centered-text" color="gray" size="sm"
x-tooltip.html="{ content: () =>
$refs.template.innerHTML,
placement: 'auto',
allowHTML: true,
theme: $store.theme,
appendTo: $root,
strategy: 'fixed',
interactive: true,
zIndex: 9999,
$refs.template.innerHTML,
placement: 'auto',
allowHTML: true,
theme: $store.theme,
class: 'tooltip',
appendTo: $root,
strategy: 'fixed',
interactive: false,
zIndex: 99999,
popperOptions: {
strategy: 'fixed',
},
}" />
</div>
@endif
@@ -0,0 +1,8 @@
<div class="flex flex-col gap-10">
<div>
{{ $this->table }}
</div>
<div>
{{ $this->form }}
</div>
</div>