Akimbo
Akimbo
FFilament
Created by Akimbo on 3/18/2025 in #❓┊help
In resources, where do I put database queries that I only want to run once?
That's a fine answer, but it brings a completely different set of problems that using a Cache brings. Caching should not be the go to for a problem with the frameworks lifecycle. Like you say, I'd expect a supplied closure to run once per row, but that's not the case with ->hidden(). Running it 5 times per row seems unnecessary. It doesn't get new parameters between each call. I will mark Mohamed's answer for now because I don't see downsides to it, but it'd be nice to see Filament have more control over stuff like this in the future.
10 replies
FFilament
Created by Akimbo on 3/18/2025 in #❓┊help
In resources, where do I put database queries that I only want to run once?
I did it as an anonymous function. As far as I'm aware, that does not make it called only once but everytime isHidden is run in Filament.
10 replies
FFilament
Created by Akimbo on 3/18/2025 in #❓┊help
In resources, where do I put database queries that I only want to run once?
And the reason this is also an issue for me is I can't get spatie laravel-permissions to actually use the cache. It uses it when getting all permissions but the can and hasPermissionTo queries don't seem to leverage the cache
10 replies
FFilament
Created by Akimbo on 3/6/2025 in #❓┊help
Can't add scripts to admin panel service provider
Looks like using asset() is the proper way to do this to prevent copying the files.
class AdminPanelProvider extends PanelProvider
{
public function boot(): void
{
FilamentAsset::register([
Js::make('app-main', asset('build/app.js')),
Css::make('custom', asset('build/custom.css')),
]);
}
class AdminPanelProvider extends PanelProvider
{
public function boot(): void
{
FilamentAsset::register([
Js::make('app-main', asset('build/app.js')),
Css::make('custom', asset('build/custom.css')),
]);
}
31 replies
FFilament
Created by Akimbo on 3/6/2025 in #❓┊help
Can't add scripts to admin panel service provider
Or is that fine
31 replies
FFilament
Created by Akimbo on 3/6/2025 in #❓┊help
Can't add scripts to admin panel service provider
So how should I do this with filament? I don't want to add the outputted vite built JS file to the FilamentAsset because then filament will collect it and put it in the public folder again
31 replies
FFilament
Created by Akimbo on 3/6/2025 in #❓┊help
Can't add scripts to admin panel service provider
I'm realizing what happened. They had imports at the top, so filament was trying to load them and ran into an error. Laravel breeze sets up Vite to compile these with babel, but filament obviously doesn't do that.
31 replies
FFilament
Created by Akimbo on 3/6/2025 in #❓┊help
Can't add scripts to admin panel service provider
Thank you, got it on the widget
31 replies
FFilament
Created by Akimbo on 3/6/2025 in #❓┊help
Can't add scripts to admin panel service provider
Having trouble getting scripts to execute in a widget as well. Is there a quick and dirty workaround to just defining a small JS function somewhere?
31 replies
FFilament
Created by Akimbo on 3/6/2025 in #❓┊help
Can't add scripts to admin panel service provider
I will try, thank you
31 replies
FFilament
Created by Akimbo on 3/6/2025 in #❓┊help
Can't add scripts to admin panel service provider
Maybe there's something funky. Just seems like the filament:assets command is moving the file but nothing is doing the automatic import. Maybe this is a difference between how Breeze now sets up Volt apps and what Filament expects the structure to be
31 replies
FFilament
Created by Akimbo on 3/6/2025 in #❓┊help
Can't add scripts to admin panel service provider
Nothing. I think I will use a widget for now to get the script on the page.
31 replies
FFilament
Created by Akimbo on 3/6/2025 in #❓┊help
Can't add scripts to admin panel service provider
I added an alert there but nothing comes up. When I search the inspector, that script isn't loaded.
31 replies
FFilament
Created by Akimbo on 3/6/2025 in #❓┊help
Can't add scripts to admin panel service provider
Is there a step to make Filament actually use the assets it finds from there? Is there a main layout page I'm supposed to edit?
31 replies
FFilament
Created by Akimbo on 3/6/2025 in #❓┊help
Can't add scripts to admin panel service provider
No, once it's put in there, there's nothing on the admin side that looks for it. The main laravel site is already importing it with Volt.
31 replies
FFilament
Created by Akimbo on 3/6/2025 in #❓┊help
Can't add scripts to admin panel service provider
Why's that?
31 replies
FFilament
Created by Akimbo on 3/6/2025 in #❓┊help
Can't add scripts to admin panel service provider
That puts it in public/js/app/app.js
31 replies
FFilament
Created by Akimbo on 3/6/2025 in #❓┊help
Can't add scripts to admin panel service provider
I did
31 replies
FFilament
Created by Akimbo on 3/6/2025 in #❓┊help
Can't add scripts to admin panel service provider
This would be my full AppServiceProvider file. Any other steps to make sure it's imported?
<?php

namespace App\Providers;

use Filament\Support\Assets\Js;
use Filament\Support\Facades\FilamentAsset;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*/
public function register(): void
{
//
}

/**
* Bootstrap any application services.
*/
public function boot(): void
{
FilamentAsset::register([
Js::make('app', __DIR__ . '/../../resources/js/app.js'),
]);
}
}
<?php

namespace App\Providers;

use Filament\Support\Assets\Js;
use Filament\Support\Facades\FilamentAsset;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*/
public function register(): void
{
//
}

/**
* Bootstrap any application services.
*/
public function boot(): void
{
FilamentAsset::register([
Js::make('app', __DIR__ . '/../../resources/js/app.js'),
]);
}
}
31 replies
FFilament
Created by Akimbo on 3/6/2025 in #❓┊help
Can't add scripts to admin panel service provider
I did add that to the app service provider. It seemed like that didn't add it either. How would this work in bootUsing? Same call?
31 replies