Quadrubo
Quadrubo
Explore posts from servers
FFilament
Created by Quadrubo on 11/23/2023 in #❓┊help
How to set the default modal action when clicking a row
Is it possible to set the default action when clicking a row to edit? I know this is possible by overwriting the recordUrl() function of the table. That however always opens a new page. I want to utilize the modals that are being used when no recordUrl is passed. Code:
Tables\Actions\ActionGroup::make([
Tables\Actions\ViewAction::make(),
Tables\Actions\EditAction::make()
->color('warning'),
Tables\Actions\DissociateAction::make(),
Tables\Actions\DeleteAction::make(),
]),
Tables\Actions\ActionGroup::make([
Tables\Actions\ViewAction::make(),
Tables\Actions\EditAction::make()
->color('warning'),
Tables\Actions\DissociateAction::make(),
Tables\Actions\DeleteAction::make(),
]),
Thanks :)
3 replies
FFilament
Created by Quadrubo on 10/19/2023 in #❓┊help
How to use $set() Closure to set the state of a fileupload
Hey, how do I use the $set() Closure to set the state of a Fileupload? Already tried setting the field to the url, path, etc. Is it possible?
1 replies
FFilament
Created by Quadrubo on 10/18/2023 in #❓┊help
Use attribute from `MorphOne` relationship in a SelectFilter
This is my filter:
Tables\Filters\SelectFilter::make('submission.status')
->options([
'draft' => 'Draft',
'published' => 'Published',
]),
Tables\Filters\SelectFilter::make('submission.status')
->options([
'draft' => 'Draft',
'published' => 'Published',
]),
It crashes with this error:
Filament\Forms\Components\Select::getRelationship(): Return value must be of type Illuminate\Database\Eloquent\Relations\BelongsTo|Illuminate\Database\Eloquent\Relations\BelongsToMany|Znck\Eloquent\Relations\BelongsToThrough|null, Illuminate\Database\Eloquent\Relations\MorphOne returned
Filament\Forms\Components\Select::getRelationship(): Return value must be of type Illuminate\Database\Eloquent\Relations\BelongsTo|Illuminate\Database\Eloquent\Relations\BelongsToMany|Znck\Eloquent\Relations\BelongsToThrough|null, Illuminate\Database\Eloquent\Relations\MorphOne returned
Is there any workaround to allowing morphOne relationships? I don't see a reason why this in particular is excluded.
2 replies
FFilament
Created by Quadrubo on 10/5/2023 in #❓┊help
Livewire lifecycle hooks not working in nested widget
Hey, I don't know if this is a filament specific or a livewire thing but I though I'd also ask here. Hey, I have 2 livewire components. One is called Map and has the property $filters. It is a filament page. The other is called MapWidget and get's the property from the Map component. It is a filament widget. Now I want to call code when the $filters property of the child component MapWidget updates. However the hooks don't seem to fire. Map:
<?php
class Map extends Page
{
public ?array $filters = [];

...
}
<?php
class Map extends Page
{
public ?array $filters = [];

...
}
<form wire:submit='create'>
...

<button type="submit">
Submit
</button>
</form>

<div>
@livewire(\App\Filament\Widgets\MapWidget::class, ['filters' => $filters])
</div>
<form wire:submit='create'>
...

<button type="submit">
Submit
</button>
</form>

<div>
@livewire(\App\Filament\Widgets\MapWidget::class, ['filters' => $filters])
</div>
MapWidget
class MapWidget extends Widget
{
public ?array $filters = [];

public function updated($property)
{
// $property: The name of the current property that was updated

dd($property);
}
}
class MapWidget extends Widget
{
public ?array $filters = [];

public function updated($property)
{
// $property: The name of the current property that was updated

dd($property);
}
}
When putting the updated function into the parent component it works as expected. I can also see that the data changes when I echo it in the view. The only thing not working are these hooks.
1 replies
FFilament
Created by Quadrubo on 9/28/2023 in #❓┊help
Form in custom field?
Is it possible to have a form inside a custom field? I'm creating a custom field in which I would like to use a filament select in combination with a leaflet map. How would one go about that? Adding the use Filament\Forms\Concerns\InteractsWithForms; trait to my Field breaks the site.
4 replies
FFilament
Created by Quadrubo on 9/27/2023 in #❓┊help
Dispatching events from filament blade components
Hey, how does one dispatch events from filament blade components, for example the button? This works fine:
<button wire:click="$dispatch('post-created')">ABC</button>
<button wire:click="$dispatch('post-created')">ABC</button>
And this does not:
<x-filament::button wire:click="$dispatch('post-created')">ABC</x-filament::button>
<x-filament::button wire:click="$dispatch('post-created')">ABC</x-filament::button>
4 replies
FFilament
Created by Quadrubo on 9/12/2023 in #❓┊help
Wire click broken in render hook
How do I make wire:click work when rendering a view from my render hook? This is a minimal example: view:
<div>
<button wire:click='test'>
Test
</button>
</div>
<div>
<button wire:click='test'>
Test
</button>
</div>
component:
<?php

namespace App\Livewire;

use Livewire\Component;

class Simple extends Component
{
public function render()
{
return view('livewire.simple');
}

public function test(): void
{
dd('test');
}
}
<?php

namespace App\Livewire;

use Livewire\Component;

class Simple extends Component
{
public function render()
{
return view('livewire.simple');
}

public function test(): void
{
dd('test');
}
}
service provider:
FilamentView::registerRenderHook(
'panels::topbar.start',
fn (): View => view('livewire.simple'),
);
FilamentView::registerRenderHook(
'panels::topbar.start',
fn (): View => view('livewire.simple'),
);
The test() function is never called. The console doesn't display anything. It seems to me like wire:click is not doing anything.
5 replies
FFilament
Created by Quadrubo on 9/8/2023 in #❓┊help
change background colour of a textinput conditionally
Hello, i want to change the background color of a textinput. I got it working using extra attributes. However only "bg-primary-500" seems to work. I want "bg-danger-500". Any way to prevent those classes from being purged?
4 replies
FFilament
Created by Quadrubo on 7/14/2023 in #❓┊help
Livewire websockets on page
Does anyone know what I'm doing wrong here? The function is not getting called.
<?php

namespace App\Filament\Pages;

// ...

class WakeComputers extends Page
{
// ...

protected $listeners = ['echo-private:computers,ComputerReachableStatusUpdated' => 'notifyNewOrder'];

public function notifyNewOrder()
{
dd("notify new order");
}

// ...
}
<?php

namespace App\Filament\Pages;

// ...

class WakeComputers extends Page
{
// ...

protected $listeners = ['echo-private:computers,ComputerReachableStatusUpdated' => 'notifyNewOrder'];

public function notifyNewOrder()
{
dd("notify new order");
}

// ...
}
I even tried enabling broadcasting in the config/filament.php.
// ...
'broadcasting' => [
'echo' => [
'broadcaster' => 'pusher',
'key' => env('VITE_PUSHER_APP_KEY'),
'cluster' => env('VITE_PUSHER_APP_CLUSTER', 'mt1'),
'wsHost' => env('VITE_PUSHER_HOST'),
'wsPort' => env('VITE_PUSHER_PORT', 80),
'wssPort' => env('VITE_PUSHER_PORT', 443),
'forceTLS' => env('VITE_PUSHER_SCHEME', 'https') === 'https',
],
],
// ...
// ...
'broadcasting' => [
'echo' => [
'broadcaster' => 'pusher',
'key' => env('VITE_PUSHER_APP_KEY'),
'cluster' => env('VITE_PUSHER_APP_CLUSTER', 'mt1'),
'wsHost' => env('VITE_PUSHER_HOST'),
'wsPort' => env('VITE_PUSHER_PORT', 80),
'wssPort' => env('VITE_PUSHER_PORT', 443),
'forceTLS' => env('VITE_PUSHER_SCHEME', 'https') === 'https',
],
],
// ...
Event is sent here:
/**
* Get the channels the event should broadcast on.
*
* @return \Illuminate\Broadcasting\Channel|array
*/
public function broadcastOn()
{
return new PrivateChannel('computers');
}
/**
* Get the channels the event should broadcast on.
*
* @return \Illuminate\Broadcasting\Channel|array
*/
public function broadcastOn()
{
return new PrivateChannel('computers');
}
Old javascript frontend could receive it:
Echo.private(`computers`).listen('ComputerReachableStatusUpdated', (e) => {
// ...
});
Echo.private(`computers`).listen('ComputerReachableStatusUpdated', (e) => {
// ...
});
2 replies
FFilament
Created by Quadrubo on 7/14/2023 in #❓┊help
Any way to set a custom notification icon color?
Using the ->iconColor() function seems to fail here:
<x-dynamic-component
:component="$icon"
:class="\Illuminate\Support\Arr::toCssClasses([
'filament-notifications-icon h-6 w-6',
match ($color) {
'success' => 'text-success-400',
'warning' => 'text-warning-400',
'danger' => 'text-danger-400',
'primary' => 'text-primary-400',
'secondary' => 'text-gray-400',
},
])"
/>
<x-dynamic-component
:component="$icon"
:class="\Illuminate\Support\Arr::toCssClasses([
'filament-notifications-icon h-6 w-6',
match ($color) {
'success' => 'text-success-400',
'warning' => 'text-warning-400',
'danger' => 'text-danger-400',
'primary' => 'text-primary-400',
'secondary' => 'text-gray-400',
},
])"
/>
1 replies
FFilament
Created by Quadrubo on 6/22/2023 in #❓┊help
Static property state does not persist
I don't know if this is a general PHP thing or has got to do with the way Filament works or I'm doing something wrong but somehow the state doesn't persist. I'm setting a static property in the getSearchResultsUsing() function and afterwards retrieve that property in the afterStateUpdated() function but it errors with the message "must not be accessed before initialization".
Forms\Components\Select::make('title')
->required()
->searchable()
->reactive()
->getSearchResultsUsing(function (string $search) {
$tmdb = new TMDBConnector;
$request = new SearchMovieRequest($search);

$response = $tmdb->send($request);

$body = $response->body();
$decodedBody = $response->json();

$results = collect($decodedBody['results']);

static::$searchResults = $results;

return $results->pluck('title', 'id');
})
->afterStateUpdated(function (Closure $set, $state) {
dd(static::$searchResults);
})
Forms\Components\Select::make('title')
->required()
->searchable()
->reactive()
->getSearchResultsUsing(function (string $search) {
$tmdb = new TMDBConnector;
$request = new SearchMovieRequest($search);

$response = $tmdb->send($request);

$body = $response->body();
$decodedBody = $response->json();

$results = collect($decodedBody['results']);

static::$searchResults = $results;

return $results->pluck('title', 'id');
})
->afterStateUpdated(function (Closure $set, $state) {
dd(static::$searchResults);
})
What is happening here? What can I do to save data between the functions or am I doing something completely wrong conceptually. Thanks in advance!
6 replies
FFilament
Created by Quadrubo on 6/14/2023 in #❓┊help
Fill form from within resource
which function does filament use to fill it's form on a resource? I wanna fill the form with model data without actually attaching a model to the form, kinda like cloning a model if that makes sense I see that the fillForm method is available on the EditRecord and the ViewRecord class. I want to use it from the resource, e.g. when a select is changed, refill the data depending on the select entry. I know I could use Closure customization but that would lead to a lot of work as I want to implement this functionality across different models with different attributes.
2 replies
IImmich
Created by Quadrubo on 5/21/2023 in #help-desk-support
Image upload not complete using CLI
The image upload is not complete when using the CLI to upload.
user@pc ~/p/g/s/T/CLI (main)> node bin/index.js upload --key KEYKEYKEY --server http://192.168.21.10:8083/api -d /home/user/output -t 16
Warning: deprecated option --directory used, this will be removed in a future release. Please specify paths with --recursive instead
Checking connectivity with Immich instance...
Server status: OK
Checking credentials...
Login status: OK
Successful authentication for user [email protected]
Indexing local assets...
Indexing complete, found 24346 local assets
Comparing local assets with those on the Immich instance...
A total of 2903 assets will be uploaded to the server
Do you want to start upload now? (y/n) y
Start uploading...
Upload Progress | █████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ | 11% || 2903/24346
Failed to upload 0 files []
user@pc ~/p/g/s/T/CLI (main)> node bin/index.js upload --key KEYKEYKEY --server http://192.168.21.10:8083/api -d /home/user/output -t 16
Warning: deprecated option --directory used, this will be removed in a future release. Please specify paths with --recursive instead
Checking connectivity with Immich instance...
Server status: OK
Checking credentials...
Login status: OK
Successful authentication for user [email protected]
Indexing local assets...
Indexing complete, found 24346 local assets
Comparing local assets with those on the Immich instance...
A total of 2903 assets will be uploaded to the server
user@pc ~/p/g/s/T/CLI (main)>
user@pc ~/p/g/s/T/CLI (main)> node bin/index.js upload --key KEYKEYKEY --server http://192.168.21.10:8083/api -d /home/user/output -t 16
Warning: deprecated option --directory used, this will be removed in a future release. Please specify paths with --recursive instead
Checking connectivity with Immich instance...
Server status: OK
Checking credentials...
Login status: OK
Successful authentication for user [email protected]
Indexing local assets...
Indexing complete, found 24346 local assets
Comparing local assets with those on the Immich instance...
A total of 2903 assets will be uploaded to the server
Do you want to start upload now? (y/n) y
Start uploading...
Upload Progress | █████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ | 11% || 2903/24346
Failed to upload 0 files []
user@pc ~/p/g/s/T/CLI (main)> node bin/index.js upload --key KEYKEYKEY --server http://192.168.21.10:8083/api -d /home/user/output -t 16
Warning: deprecated option --directory used, this will be removed in a future release. Please specify paths with --recursive instead
Checking connectivity with Immich instance...
Server status: OK
Checking credentials...
Login status: OK
Successful authentication for user [email protected]
Indexing local assets...
Indexing complete, found 24346 local assets
Comparing local assets with those on the Immich instance...
A total of 2903 assets will be uploaded to the server
user@pc ~/p/g/s/T/CLI (main)>
As you can see the CLI stops uploading after the 2903 images are uploaded, as expected. However when starting the CLI again, it still finds the 2903 assets that don't match Online I can see that I have 21445 assets uploaded, in the output folder there are 24346 which means exactly 2901 photos failed to upload which still doesn't match the 2903 exactly but get's me closer
124 replies
FFilament
Created by Quadrubo on 3/12/2023 in #❓┊help
Can't set DatePicker as required
Hello, I'm using the Form Builder on a custom Widget of mine. I can't set the DatePicker as required, a TextInput or a Select works as usual. When I click submit without filling the textinput the field says it's required, on the datepicker this doesn't happen.
class TransactionSum extends Widget implements HasForms
{
use InteractsWithForms;

public string $until = '';
public string $test = '';

protected function getFormSchema(): array
{
return [
Forms\Components\TextInput::make('test')
->required(), // this one is working
Forms\Components\DatePicker::make('until')
->required(), // this one is not
// ...
];
}
class TransactionSum extends Widget implements HasForms
{
use InteractsWithForms;

public string $until = '';
public string $test = '';

protected function getFormSchema(): array
{
return [
Forms\Components\TextInput::make('test')
->required(), // this one is working
Forms\Components\DatePicker::make('until')
->required(), // this one is not
// ...
];
}
5 replies
FFilament
Created by Quadrubo on 3/9/2023 in #❓┊help
Is it possible to use the Table builder without a Query?
I'd want to use the table builder without using a Query. I have my own data defined as an array or really anything I want to and want to render that as a table, I'd also be fine with using some kind of table component in livewire, it would be for viewing only. Right now I have to implement the getTableQuery method which I don't have.
7 replies
FFilament
Created by Quadrubo on 3/7/2023 in #❓┊help
How to make my method execute a Closure
Hello, I'm writing a custom function inside my action which should accept a Closure.
public function autofill(array|Closure $data): void
{
$this->url(AssignmentResource::getUrl('create', $data));
}
public function autofill(array|Closure $data): void
{
$this->url(AssignmentResource::getUrl('create', $data));
}
Right now this gives the error, Object of class Closure could not be converted to string. Looking at other methods I couldn't find a difference, how do you do this?
5 replies
FFilament
Created by Quadrubo on 3/7/2023 in #❓┊help
Autofill fields from url
hey, is there a way to autofill fileds from the url? I have created this action which links to the Create Page of a resource, I want to have a few fields prefilled, depending on the action. Here is what i tried, want to fill the field named iban with the value DE90BLABLA
return Action::make('quick_create_assignment')
->label('Quick Create')
->url(fn ($livewire) => AssignmentResource::getUrl('create', ['iban' => 'DE90BLABLA']]));
return Action::make('quick_create_assignment')
->label('Quick Create')
->url(fn ($livewire) => AssignmentResource::getUrl('create', ['iban' => 'DE90BLABLA']]));
12 replies