ChesterS
ChesterS
FFilament
Created by ChesterS on 7/1/2024 in #❓┊help
URL not working in repeater action?
RepeatableEntry::make('items')
->schema([
TextEntry::make('edit')
->hiddenLabel()
->state('Edit')
->icon('heroicon-m-pencil-square')
->action(
Action::make('edit')
->label('Edit')
->icon('heroicon-m-pencil-square')
->action(fn ($record) => redirect(EditItem::getUrl(['record' => $record]))) // This works
->url(fn ($record) => EditItem::getUrl(['record' => $record])) // This DOESNT for some reason...
),
RepeatableEntry::make('items')
->schema([
TextEntry::make('edit')
->hiddenLabel()
->state('Edit')
->icon('heroicon-m-pencil-square')
->action(
Action::make('edit')
->label('Edit')
->icon('heroicon-m-pencil-square')
->action(fn ($record) => redirect(EditItem::getUrl(['record' => $record]))) // This works
->url(fn ($record) => EditItem::getUrl(['record' => $record])) // This DOESNT for some reason...
),
For some reason, using the url(...) method doeson't work. The generated $wire.target= is empty and as a result throws a console error
Alpine Expression Error: missing name after . operator

Expression: "$wire."

<button class="block" type="button" wire:click="" wire:loading.attr="disabled" wire:target="">
Alpine Expression Error: missing name after . operator

Expression: "$wire."

<button class="block" type="button" wire:click="" wire:loading.attr="disabled" wire:target="">
Am i doing something wrong? The URL is obviously correct since it works when I manually redirect() to it.
2 replies
FFilament
Created by ChesterS on 4/29/2024 in #❓┊help
Vite manifest not found when registering custom asset and deploying to production
I have a weird issue when trying to deploy to production. I have a custom asset loaded using
FilamentAsset::register([
Js::make('echo', Vite::asset('resources/js/echo.js')),
]);
FilamentAsset::register([
Js::make('echo', Vite::asset('resources/js/echo.js')),
]);
However, during composer's post-autoload-dump the following commands are executed
"@php artisan package:discover --ansi",
"@php artisan filament:assets"
"@php artisan package:discover --ansi",
"@php artisan filament:assets"
both of which fail because the Vite manifest hasn't been generated yet. The manifest is generated when I ran npm run build but I can't do that because this fails if I haven't installed the composer dependencies yet. So I'm in this weird catch-22 where the composer step fails because I can't build the Vite manifest, and I can't build the Vite manifest because the composer step fails. Removing the FillamentAsset::register... code solves the issue but it's obviously not a solution so I wonder if I'm missing something. I use Forge/Envoyer for the deployments so most steps are vanilla Envoyer stuff. All of it worked untill I wanted to load a custom asset. The manifest is not commited into the repo BTW. Am I supposed to commit it?
34 replies
FFilament
Created by ChesterS on 4/24/2024 in #❓┊help
`requiresConfirmation(false)` still shows confirmation dialog for Delete action
I have the following table action
Actions\DeleteAction::make('delete'))
->icon('heroicon-o-check')
->iconButton()
->requiresConfirmation(false),
Actions\DeleteAction::make('delete'))
->icon('heroicon-o-check')
->iconButton()
->requiresConfirmation(false),
However, I'm still getting a generic confirmation dialog when I click the button. Am I missing something?
Laravel 10.48.8
Filament v3.2.71
Livewire v3.4.10
Laravel 10.48.8
Filament v3.2.71
Livewire v3.4.10
2 replies
FFilament
Created by ChesterS on 4/3/2024 in #❓┊help
Enable Echo.js without breaking Hot Reload
Ok I'm at my wit's end here... I know this is probably not strictly Filament related, but maybe there's a JS wizard here that can help I'm trying to enable broadcasting. Here are the relevant files
// echo.js
import Echo from 'laravel-echo';
import Pusher from 'pusher-js';

window.Pusher = Pusher;

window.Echo = new Echo({
broadcaster: 'reverb',
...
enabledTransports: ['ws', 'wss'],
});
// echo.js
import Echo from 'laravel-echo';
import Pusher from 'pusher-js';

window.Pusher = Pusher;

window.Echo = new Echo({
broadcaster: 'reverb',
...
enabledTransports: ['ws', 'wss'],
});
// AppServiceProvider.php
FilamentAsset::register([
Js::make('echo', Vite::asset('resources/js/echo.js')),
]);
// AppServiceProvider.php
FilamentAsset::register([
Js::make('echo', Vite::asset('resources/js/echo.js')),
]);
//vite.config.js
export default defineConfig({
plugins: [
laravel({
input: [
'resources/css/app.css',
'resources/js/app.js',
'resources/js/echo.js',
'resources/css/filament/theme.css',
],
}),
],

});
//vite.config.js
export default defineConfig({
plugins: [
laravel({
input: [
'resources/css/app.css',
'resources/js/app.js',
'resources/js/echo.js',
'resources/css/filament/theme.css',
],
}),
],

});
As you can see, most of the code is boilerplate. It works when I run npm run build , but when I run npm run dev I get the following error.
Uncaught SyntaxError: import.meta may only appear in a module
Uncaught SyntaxError: import.meta may only appear in a module
in firefox and
Uncaught SyntaxError: Cannot use 'import.meta' outside a module
Uncaught SyntaxError: Cannot use 'import.meta' outside a module
inside the echo.js file
import.meta.env = {"VITE_PUSHER_APP_KEY":"","VITE ....
import.meta.env = {"VITE_PUSHER_APP_KEY":"","VITE ....
Has anyone run into something similar? Any suggestions? Googling for this error doesn't get me anything useful.
5 replies
FFilament
Created by ChesterS on 4/1/2024 in #❓┊help
Load custom component inside action modal
Ok I think I'm missing something obvious here, but is there a way to load a custom Livewire component inside a modal action? Here's an example of what I've tried
use Filament\Infolists\Components\Actions\Action;

Action::make('something')
// ->modalContent(view('livewire.my-modal')) // This doesn't work either since it's just the view
->livewire(new MyCustomComponent())
use Filament\Infolists\Components\Actions\Action;

Action::make('something')
// ->modalContent(view('livewire.my-modal')) // This doesn't work either since it's just the view
->livewire(new MyCustomComponent())
but it doesn't work (the modal is empty) This is what my component looks like
class MyCustomComponent extends Component implements HasActions, HasForms, HasTable
{
use HasTabs;
use InteractsWithActions;
use InteractsWithForms;
use InteractsWithTable {
makeTable as makeBaseTable;
}

public function mount(): void
{
...
}

public function render(): View
{
return view('livewire.my-modal');
}
}
class MyCustomComponent extends Component implements HasActions, HasForms, HasTable
{
use HasTabs;
use InteractsWithActions;
use InteractsWithForms;
use InteractsWithTable {
makeTable as makeBaseTable;
}

public function mount(): void
{
...
}

public function render(): View
{
return view('livewire.my-modal');
}
}
9 replies
FFilament
Created by ChesterS on 2/27/2024 in #❓┊help
Create action with relation throws error
Sorry for the vague title I have the following action
Actions\Action::make('createUser')
->form([
TextInput::make('email'),
Select::make('roles')
->multiple()
->searchable(false)
->preload()
->options(Roles::options()) // This is an enum
->getOptionLabelFromRecordUsing(fn (Role $record) => Roles::from($record->name)->getLabel())
->relationship('roles', 'name'),
])

->action(function ($record, array $data) {
$record->user()->create($data);
})
Actions\Action::make('createUser')
->form([
TextInput::make('email'),
Select::make('roles')
->multiple()
->searchable(false)
->preload()
->options(Roles::options()) // This is an enum
->getOptionLabelFromRecordUsing(fn (Role $record) => Roles::from($record->name)->getLabel())
->relationship('roles', 'name'),
])

->action(function ($record, array $data) {
$record->user()->create($data);
})
When I click on the button, I get the following error
Filament\Support\Services\RelationshipJoiner::prepareQueryForNoConstraints(): Argument #1 ($relationship) must be of type Illuminate\Database\Eloquent\Relations\Relation, null given, called in /var/www/.../vendor/filament/forms/src/Components/Select.php on line 765
Filament\Support\Services\RelationshipJoiner::prepareQueryForNoConstraints(): Argument #1 ($relationship) must be of type Illuminate\Database\Eloquent\Relations\Relation, null given, called in /var/www/.../vendor/filament/forms/src/Components/Select.php on line 765
This is the exact same form I use in the UserResource and it works when creating a new user, but for some reason doesn't work when doing it outside the resource. I tried adding
->model(User::class)
->model(User::class)
and some other things but nothing worked. What am I doing wrong?
5 replies
FFilament
Created by ChesterS on 2/2/2024 in #❓┊help
Refresh Filament component from a custom one
I have the following infolist
return $infolist->schema([
...
Section::make()
->schema([
Livewire::make(MyCustomComponent::class)
]),
]);
return $infolist->schema([
...
Section::make()
->schema([
Livewire::make(MyCustomComponent::class)
]),
]);
Is there a way to trigger the infolist to update from inside MyCustomComponent? I can listen for an event inside the my filament ViewRecord class, but I'm not sure how to trigger the actual update/refresh. I'd rather avoid a full page reload. Ideally, I would have the same behaviour actions have (eg only the infolist is updated)
5 replies
FFilament
Created by ChesterS on 1/23/2024 in #❓┊help
toggleable() not working with Split?
I have the following table columns
Split::make([
TextColumn::make('status')
->badge()
->grow(false)
->toggleable(isToggledHiddenByDefault: true)
->label(__('Status')),
TextColumn::make('created_at')
->toggleable(isToggledHiddenByDefault: true)
->sortable()
->toggledHiddenByDefault(true) // I know it's useless, just here for the example
])->from('md'),
Split::make([
TextColumn::make('status')
->badge()
->grow(false)
->toggleable(isToggledHiddenByDefault: true)
->label(__('Status')),
TextColumn::make('created_at')
->toggleable(isToggledHiddenByDefault: true)
->sortable()
->toggledHiddenByDefault(true) // I know it's useless, just here for the example
])->from('md'),
However, the column is always visible. When I click on the on the checkbox to toggle its visibility, the only thing that changes is that the option disappears from the sorting dropdown. If I remove the Split::make() part and only have the columns, it works as expected Is toggleable() not compatible with Split or am I doing something wrong?
8 replies
FFilament
Created by ChesterS on 1/9/2024 in #❓┊help
Apply filters button + Filters as a slide-over
2 questions really 1) I remember there was a PR that added an Apply button to filters so the table was only filtered when you clicked the button and not when the filters where changed. Do I remember correctly? 2) How do I show the table filters in a slide-over? I set the layout: FiltersLayout::Modal but how do I change it to a slide over?
7 replies
FFilament
Created by ChesterS on 1/3/2024 in #❓┊help
Custom `target` attribute in link Action
Not sure if this is an IBKAC but I can't set a custom target on a link Action. Here is the code
Action::make('link')
->extraAttributes([
'target' => 'does_not_work',
'random_shit' => 'this_works',
])
->link()
Action::make('link')
->extraAttributes([
'target' => 'does_not_work',
'random_shit' => 'this_works',
])
->link()
For some reason, the target attribute does not appear but anything else seems to work. Am I missing something? Is the target attribute filtered for some reason? (I don't want to use openUrlInNewTab() since I don't want to open it in a new tab)
4 replies
FFilament
Created by ChesterS on 12/19/2023 in #❓┊help
`visible()` doesn't resolve record
I have the following Table
public function table(Table $table): Table
{
return $table
->query(...)
->columns([
IconColumn::make('visible_to_everyone')
->visible(fn (MyModel $record) => ! $record->created_by_admin) // Problem is here
])
;
}
public function table(Table $table): Table
{
return $table
->query(...)
->columns([
IconColumn::make('visible_to_everyone')
->visible(fn (MyModel $record) => ! $record->created_by_admin) // Problem is here
])
;
}
Which throws the following error
Argument #1 ($record) must be of type App\Models\MyModel, null given, called in /var/www/endor/vendor/filament/support/src/Concerns/EvaluatesClosures.php on line 35
Argument #1 ($record) must be of type App\Models\MyModel, null given, called in /var/www/endor/vendor/filament/support/src/Concerns/EvaluatesClosures.php on line 35
Am I missing something? It doesn't matter what type of column I use BTW, when I pass a closure to the visible method, it doesn't pass he record as expected. Everything is up-to-date (LW 3.3, Filament 3.1.23)
7 replies
FFilament
Created by ChesterS on 12/14/2023 in #❓┊help
Call to a member function getInfolist() on null
I'm trying to create a custom Infolist action, but I'm getting the following error Call to a member function getInfolist() on null This is the action I've created
class CustomLinkAction extends Action
{
// use CanCustomizeProcess; // I added this because I thought it was needed but it didn't help

public static function getDefaultName(): ?string
{
return 'customLink';
}

protected function setUp(): void
{
parent::setUp();

// The following line throws the error. But anything that uses `$this` seems to throw the same error
$this->url($this->getRecord()->getCustomUrl());
}
}
class CustomLinkAction extends Action
{
// use CanCustomizeProcess; // I added this because I thought it was needed but it didn't help

public static function getDefaultName(): ?string
{
return 'customLink';
}

protected function setUp(): void
{
parent::setUp();

// The following line throws the error. But anything that uses `$this` seems to throw the same error
$this->url($this->getRecord()->getCustomUrl());
}
}
8 replies
FFilament
Created by ChesterS on 11/29/2023 in #❓┊help
Why do my tabs look different?
No description
3 replies
FFilament
Created by ChesterS on 11/23/2023 in #❓┊help
Set formData on an Infolist action form
I have the following infolist action form (excerpt)
TextEntry::make('user.details')
->suffixActions([
Action::make('editDetails')
->form([
TextInput::make('name'),
Select::make('title')
])
->formData([]) // Cant set this
->action(function (array $data, $record) {
$record->details()->update($data);
}),
])
TextEntry::make('user.details')
->suffixActions([
Action::make('editDetails')
->form([
TextInput::make('name'),
Select::make('title')
])
->formData([]) // Cant set this
->action(function (array $data, $record) {
$record->details()->update($data);
}),
])
How can I pre-fill this form? I tried doing the following
$details = $this->getRecord()->details->attributesToArray();

...

->formData($details)
$details = $this->getRecord()->details->attributesToArray();

...

->formData($details)
but it doesn't work. Is this possible? Am I doing something wrong?
3 replies
FFilament
Created by ChesterS on 11/21/2023 in #❓┊help
File upload fails the first time but works afterwards when in a slide-over
Ok I have this weird issue. Here is my setup This is the custom action I'm using to show a slide-over on a table. It contains a custom component that has a form with a file upload.
Action::make('messages')
->icon('heroicon-o-envelope')
->modalContent(fn ($record) => view('livewire.common.messaging-wrapper', [
'id' => $record->id,
]))
->slideOver(),
Action::make('messages')
->icon('heroicon-o-envelope')
->modalContent(fn ($record) => view('livewire.common.messaging-wrapper', [
'id' => $record->id,
]))
->slideOver(),
this is the wrapper
@props(['object_id'])
<div>
@if(auth()->user()->is_admin)
<livewire:common.admin-messaging :id=$object_id/>
@else
<livewire:common.customer-messaging :id=$object_id/>
@endif
</div>
@props(['object_id'])
<div>
@if(auth()->user()->is_admin)
<livewire:common.admin-messaging :id=$object_id/>
@else
<livewire:common.customer-messaging :id=$object_id/>
@endif
</div>
Here is the form
Textarea::make('message')
->label(__('Message'))
->required(),
SpatieMediaLibraryFileUpload::make('media')
->label('Attachments')
->multiple()
->directory(config('filesystems.paths.images.messages'))
->visibility('private'),
Textarea::make('message')
->label(__('Message'))
->required(),
SpatieMediaLibraryFileUpload::make('media')
->label('Attachments')
->multiple()
->directory(config('filesystems.paths.images.messages'))
->visibility('private'),
Most of it is boilerplate, and it works fine when I use it in a page (I use the same wrapper). However, when I use this in a slide over as a custom action, the first time I try to upload an image, it fails and I get the following console error At first I thought it might have been an issue with the table polling, but I've disabled it and the issue is still there. If I try to upload something again, it works as expected. I know this is a weird issue, so any ideas are welcome.
7 replies
FFilament
Created by ChesterS on 11/17/2023 in #❓┊help
Remove/Disable record action on table
Is there a way to disable/remove the default click action on a table row? Clicking on a table takes you to the form. Is there a way to disable this? I've tried things like ->recordAction(false) or ->recordAction(null) but it doesn't work.
4 replies
FFilament
Created by ChesterS on 11/7/2023 in #❓┊help
Access to table records in resource
Is there a way to get a list of all the records from the table? When using the tables with a Livewire component it was easy since you could do something like
$this->table->getRecords()
$this->table->getRecords()
But with resources, all methods are static and I'm not sure how to achieve the same result. Any tips welcome.
2 replies
FFilament
Created by ChesterS on 11/6/2023 in #❓┊help
Filament + app layout
How does Filament decide which layout to use? I've followed the setup instructions and and have a resources/views/components/layouts/app.blade.php file, but I'm pretty sure it's not using it 🤔 Here is my layout (it's mostly vanilla with some changes)
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="csrf-token" content="{{ csrf_token() }}">

<meta name="application-name" content="{{ config('app.name') }}" />
<meta name="csrf-token" content="{{ csrf_token() }}" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" href="{{ asset('favicon.png') }}" type="image/png" />

<title>{{ config('app.name') }}</title>

<style>
[x-cloak] {
display: none !important;
}
</style>
@vite('resources/css/app.css')
@stack('styles')
@livewireStyles
@filamentStyles
</head>
<body class="font-sans antialiased">
<div class="min-h-screen bg-gray-100">
<livewire:navigation/>

<!-- Page Content -->
<main>
{{ $slot }}

@livewireScriptConfig
@filamentScripts
@livewire('notifications')
@vite('resources/js/app.js')
@stack('scripts')
</main>
</div>
</body>
</html>
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="csrf-token" content="{{ csrf_token() }}">

<meta name="application-name" content="{{ config('app.name') }}" />
<meta name="csrf-token" content="{{ csrf_token() }}" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" href="{{ asset('favicon.png') }}" type="image/png" />

<title>{{ config('app.name') }}</title>

<style>
[x-cloak] {
display: none !important;
}
</style>
@vite('resources/css/app.css')
@stack('styles')
@livewireStyles
@filamentStyles
</head>
<body class="font-sans antialiased">
<div class="min-h-screen bg-gray-100">
<livewire:navigation/>

<!-- Page Content -->
<main>
{{ $slot }}

@livewireScriptConfig
@filamentScripts
@livewire('notifications')
@vite('resources/js/app.js')
@stack('scripts')
</main>
</div>
</body>
</html>
5 replies
FFilament
Created by ChesterS on 11/3/2023 in #❓┊help
`php artisan filament:install --panels` fails for non-admin input
No description
5 replies
FFilament
Created by ChesterS on 10/30/2023 in #❓┊help
Using Table + Tabs in custom Livewire component
No description
10 replies