Flo
Flo
Explore posts from servers
FFilament
Created by Flo on 12/26/2023 in #❓┊help
Disable sub-navigation on specify page
Hello, is it possible to disable the sub-navigation resource on certain pages only? I have a resource that has a public function getRecordSubNavigation, but I want to hide it on a specific page of type ViewRecord. This page is not included in the menu, but I want to disable this menu for this page. Is it possible ?
11 replies
FFilament
Created by Flo on 12/21/2023 in #❓┊help
Modal does not work in a Custom Page
Hello, I am building a custom page but nothing happens when I click on the column action :
/* @method Server getRecord() */
class SoftwareServer extends Page implements HasActions, HasTable
{
use InteractsWithRecord, InteractsWithTable;

protected static string $resource = ServerResource::class;

public function mount(int|string $record): void
{
$this->record = $this->resolveRecord($record);

static::authorizeResourceAccess();
}

public function table(Table $table): Table
{
return $table
->query(Software::queryForSoftwares($this->getRecord()))
->columns([
TextColumn::make('name'),
])
->actions([
Tables\Actions\Action::make('test')
->label('Test')
->form([
TextInput::make('name'),
])
->action(fn (array $data) => dd($data)),
])
->paginated(false);
}
}
/* @method Server getRecord() */
class SoftwareServer extends Page implements HasActions, HasTable
{
use InteractsWithRecord, InteractsWithTable;

protected static string $resource = ServerResource::class;

public function mount(int|string $record): void
{
$this->record = $this->resolveRecord($record);

static::authorizeResourceAccess();
}

public function table(Table $table): Table
{
return $table
->query(Software::queryForSoftwares($this->getRecord()))
->columns([
TextColumn::make('name'),
])
->actions([
Tables\Actions\Action::make('test')
->label('Test')
->form([
TextInput::make('name'),
])
->action(fn (array $data) => dd($data)),
])
->paginated(false);
}
}
And the associated view:
<x-filament-panels::page>
{{ $this->table }}

<x-filament-actions::modals/>
</x-filament-panels::page>
<x-filament-panels::page>
{{ $this->table }}

<x-filament-actions::modals/>
</x-filament-panels::page>
Why ? In the browser console, an ajax call to the /livewire/update route appears correctly
20 replies
FFilament
Created by Flo on 12/19/2023 in #❓┊help
Widget Table "Cannot use "::class" on null" error
Hello, I am trying to add a Table to a page that extends from "ManageRelatedRecords". So in this one I included the widget on "class DatabaseServer extends ManageRelatedRecords":
protected function getHeaderWidgets(): array
{
return[
ServerResource\Widgets\CreateDatabaseUserWidget::make([
'server' => $this->getRecord(),
]),
];
}
protected function getHeaderWidgets(): array
{
return[
ServerResource\Widgets\CreateDatabaseUserWidget::make([
'server' => $this->getRecord(),
]),
];
}
And in my ServerResource page I declared the widget:
public static function getWidgets(): array
{
return[
ServerResource\Widgets\CreateDatabaseUserWidget::class,
];
}
public static function getWidgets(): array
{
return[
ServerResource\Widgets\CreateDatabaseUserWidget::class,
];
}
And here is my Widget page:
<?php

namespace App\Filament\Resources\ServerResource\Widgets;

use App\Models\Server;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
use Filament\Widgets\TableWidget as BaseWidget;
use Illuminate\Database\Eloquent\Builder;

class CreateDatabaseUserWidget extends BaseWidget
{
public Server $server;

public function table(Table $table): Table
{
return $table
->query(fn (Builder $query) => $query
->where('server_id', $this->server->id)
)
->columns([
TextColumn::make('id'),
]);
}
}
<?php

namespace App\Filament\Resources\ServerResource\Widgets;

use App\Models\Server;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
use Filament\Widgets\TableWidget as BaseWidget;
use Illuminate\Database\Eloquent\Builder;

class CreateDatabaseUserWidget extends BaseWidget
{
public Server $server;

public function table(Table $table): Table
{
return $table
->query(fn (Builder $query) => $query
->where('server_id', $this->server->id)
)
->columns([
TextColumn::make('id'),
]);
}
}
Here is the trace:
[2023-12-19 14:31:58] local.ERROR: Cannot use "::class" on null {"userId":"*******","exception":"[object] (TypeError (code: 0): Cannot use \"::class\" on null at path/to/directory/vendor/filament/tables/src/Table/Concerns/HasRecords.php:76)
[stacktrace]
[2023-12-19 14:31:58] local.ERROR: Cannot use "::class" on null {"userId":"*******","exception":"[object] (TypeError (code: 0): Cannot use \"::class\" on null at path/to/directory/vendor/filament/tables/src/Table/Concerns/HasRecords.php:76)
[stacktrace]
3 replies