Albert Lens
Albert Lens
FFilament
Created by Albert Lens on 5/28/2024 in #❓┊help
->RenderHook() problem in AdminPanelProvider.php | Class "Filament\View\PanelsRenderHook" not found
Hello. I had this same configuration in my last application two months ago and had no problems. For this new application I am beginning now, I wanted to have the same exact renderHook and used the same in AdminPanelProvider.php
->renderHook(
PanelsRenderHook::TOPBAR_START,
fn(): View => view('filament.settings.custom-footer'),
);
And then I have the error:
Class "Filament\View\PanelsRenderHook" not found
->renderHook(
PanelsRenderHook::TOPBAR_START,
fn(): View => view('filament.settings.custom-footer'),
);
And then I have the error:
Class "Filament\View\PanelsRenderHook" not found
It looks to me as if something is still pending to be installed, because in my previous application where it is working I can right click over the word PanelsRenderHook and click on "Go to definition" and it opens: vendor\filament\filament\src\View\PanelsRenderHook.php But with his new one it says it cannot find the definition file "Definition not found". Any ideas of what I am missing. Thank you
10 replies
FFilament
Created by Albert Lens on 3/23/2024 in #❓┊help
Mail problem rendering view with data with two arrays
Hello. I have a row action which lets users send email with attached Pdf with some info about the record. Everything works fine. Now I want the user can change subject and body of the email and I have included a form and user can type.
Action::make('enviarporEmail')->label('')->modalDescription('ddd')
->form([
TextInput::make('email')
->label('Email al que enviar:')
->email()
->default(Auth()->user()->email)
->required(),
TextInput::make('asunto')
...
Action::make('enviarporEmail')->label('')->modalDescription('ddd')
->form([
TextInput::make('email')
->label('Email al que enviar:')
->email()
->default(Auth()->user()->email)
->required(),
TextInput::make('asunto')
...
And it works fine till then. I launch the mail with the data:
->action(function (array $data,Expediente $record) {
$receivers = $data['email'];
$expediente = Expediente::find($record->id);
Mail::to($receivers)
->send(new ExpedienteCarpetaEmail ($expediente, $data));
})

And I can check inside the __construct of the mail controller that data arrives correctly:
public $expediente;
public $data;
public function __construct(Expediente $expediente, $data)
{
// dd($data);
if (!$data['asunto']) {
$this->subject('Información del expediente ' . $expediente->numExp);
} else {
$this->subject($data['asunto']);
}
$this->expediente = $expediente;
Pdf::view('expedientes.carpetaA4', ['expediente' => $expediente])
->format('a4')
->save('carpeta-'. $expediente->numExp .'.pdf');
// $this->content('expedientes.email', $data = $data);
$this->content(fn () => view('expedientes.email', ['expediente' => $expediente, 'data' => $data]));
$this->attach('carpeta-'. $expediente->numExp .'.pdf');
}

And inside the final view (expedientes.email) of the final step it thows an error of:
Undefined variable $data (View: ...
->action(function (array $data,Expediente $record) {
$receivers = $data['email'];
$expediente = Expediente::find($record->id);
Mail::to($receivers)
->send(new ExpedienteCarpetaEmail ($expediente, $data));
})

And I can check inside the __construct of the mail controller that data arrives correctly:
public $expediente;
public $data;
public function __construct(Expediente $expediente, $data)
{
// dd($data);
if (!$data['asunto']) {
$this->subject('Información del expediente ' . $expediente->numExp);
} else {
$this->subject($data['asunto']);
}
$this->expediente = $expediente;
Pdf::view('expedientes.carpetaA4', ['expediente' => $expediente])
->format('a4')
->save('carpeta-'. $expediente->numExp .'.pdf');
// $this->content('expedientes.email', $data = $data);
$this->content(fn () => view('expedientes.email', ['expediente' => $expediente, 'data' => $data]));
$this->attach('carpeta-'. $expediente->numExp .'.pdf');
}

And inside the final view (expedientes.email) of the final step it thows an error of:
Undefined variable $data (View: ...
The view can manage $expediente->whateverfield correctly but $data is undefined. Any ideas, please?
3 replies
FFilament
Created by Albert Lens on 3/22/2024 in #❓┊help
Row action confirmation message is blank
No description
6 replies
FFilament
Created by Albert Lens on 3/21/2024 in #❓┊help
How can I automatically launch a function when user enters a Resource list page?
I need to update some data before users access the mediaResource list page (table). What would be a correct approach to automatically launch the function I need as soon as user enters that url (https://apps.geslem.com/media) ? For the moment, I have put a button that users have to click to run the funcion:
->HeaderActions([
Action::make('Actualizar')
->color('amber')
->action( function () {
(new MediaService())->recalculaMediaNumExp();
}),
]
->HeaderActions([
Action::make('Actualizar')
->color('amber')
->action( function () {
(new MediaService())->recalculaMediaNumExp();
}),
]
Any ideas, please? Tks in advance.
3 replies
FFilament
Created by Albert Lens on 3/19/2024 in #❓┊help
RenderHook css problem in login page (dark / light theme)
Hello. I am using a PanelsRenderHook::TOPBAR_START to render a copyright view in my application and it is working fine using CSS for dark or light mode.
->renderHook(
PanelsRenderHook::TOPBAR_START,
fn(): View => view('filament.settings.custom-footer'),
);
->renderHook(
PanelsRenderHook::TOPBAR_START,
fn(): View => view('filament.settings.custom-footer'),
);
Working fine with this CSS to know whether it is dark or light mode: My CSS:
div class="hidden dark:flex">
<a href="https://robustdatasolutions.com" target="_blank" ><img src="/img/robust_invert.png" alt="" style="align:center; width:25px;height:25px;margin-right:5px"></a>
<a href="https://robustdatasolutions.com" target="_blank" class="textoCopyRightLogin"> <strong>Robust Expedientes</strong> &copy; {{ date('Y') }} Robust Data Solutions</a>
</div>
{{-- Theme is dark --}}

div class="flex dark:hidden" style="display:flex; align-items:left;justify-content: center;">
<a href="https://robustdatasolutions.com" target="_blank" ><img src="/img/robust.png" alt="" style="align:center; width:25px;margin-right:5px;"></a>
<a href="https://robustdatasolutions.com" target="_blank" class="textoCopyRightLogin"><strong>Robust Expedientes</strong> &copy; {{ date('Y') }} Robust Data Solutions</a>
</div>
{{-- Theme is light --}}
div class="hidden dark:flex">
<a href="https://robustdatasolutions.com" target="_blank" ><img src="/img/robust_invert.png" alt="" style="align:center; width:25px;height:25px;margin-right:5px"></a>
<a href="https://robustdatasolutions.com" target="_blank" class="textoCopyRightLogin"> <strong>Robust Expedientes</strong> &copy; {{ date('Y') }} Robust Data Solutions</a>
</div>
{{-- Theme is dark --}}

div class="flex dark:hidden" style="display:flex; align-items:left;justify-content: center;">
<a href="https://robustdatasolutions.com" target="_blank" ><img src="/img/robust.png" alt="" style="align:center; width:25px;margin-right:5px;"></a>
<a href="https://robustdatasolutions.com" target="_blank" class="textoCopyRightLogin"><strong>Robust Expedientes</strong> &copy; {{ date('Y') }} Robust Data Solutions</a>
</div>
{{-- Theme is light --}}
The problem is that for the login page I am using:
FilamentView::registerRenderHook(
PanelsRenderHook::AUTH_LOGIN_FORM_AFTER,
fn (): View => view('filament.settings.custom-footer-login'),
);
FilamentView::registerRenderHook(
PanelsRenderHook::AUTH_LOGIN_FORM_AFTER,
fn (): View => view('filament.settings.custom-footer-login'),
);
and the same CSS which works inside the application is NOT WORKING FINE in the login page. It is able to know when theme is dark, but it shows both logos (dark mode and light mode ones) when theme is light. Any ideas, please?
4 replies
FFilament
Created by Albert Lens on 3/10/2024 in #❓┊help
Tailwind help please
Now that my application is developed at 90% it is time to customize styling details. I have begun customizing my own Tailwind classes but NOTHING HAPPENS. Very probably I am doing something wrong. I have followed the OD (Official Docs) here: https://filamentphp.com/docs/3.x/notifications/installation#installing-tailwind-css For example, I have a resource table where I want to customize the row according to one $record->value, like this:
->recordClasses(fn (Model $record) => match ($record->facturado) {
true => 'facturadoClass',
default => null,
})
->recordClasses(fn (Model $record) => match ($record->facturado) {
true => 'facturadoClass',
default => null,
})
And in my resources\css\app.css file I have put my new class:
@tailwind base;
@tailwind components;
@tailwind utilities;

.facturadoClass {
@apply bg-blue-500 text-white font-bold py-2 px-4 rounded;
}
@tailwind base;
@tailwind components;
@tailwind utilities;

.facturadoClass {
@apply bg-blue-500 text-white font-bold py-2 px-4 rounded;
}
And I run npm run build What am I missing or doing wrong, please???
6 replies
FFilament
Created by Albert Lens on 3/7/2024 in #❓┊help
How to validate repeater items certain conditions before create - Attributes IN repeater items
Hello. Not possible with observer or with mutateFormDataBeforeCreate I have a form to create dossiers, and each dossier can have multiple interveners; I am using a repeater. I need to validate, for example, if there are 3 interveners and not all 3 have the field invoiceable == true then halt and prevent the user from saving the Dossier and make Notification. The fact is that if I use mutateFormDataBeforeCreate(array $data): array and I dd(data); I see no interveners array (no array for the repeater) and I cannot check. Also, using an Observer, in the creating function, attributes DO NOT include repeaters, so this always gives an empty array for the interveners repeater (hasMany RelationShip):
public function creating(Expediente $expediente): void
{
$cuentaIntervinientes= $expediente->intervinientes->count();
$cuentaIntervinientesFacturables= $expediente->intervinientes->where('facturable',true)->count();
dd($cuentaIntervinientesFacturables, $cuentaIntervinientes);
if ($cuentaIntervinientesFacturables == $cuentaIntervinientes && $cuentaIntervinientes == 1){
//
} elseif ($cuentaIntervinientesFacturables == 0){
...
throw new Halt();
} elseif ($cuentaIntervinientesFacturables > 1 && $cuentaIntervinientesFacturables < $cuentaIntervinientes){
Notification::make()
->title('No todos los intervinientes son facturables. O todos o sólo uno')
->body('El expediente ' . $expediente->numExp . ' tiene ' . $cuentaIntervinientesFacturables . ' intervinientes facturables de ' . $cuentaIntervinientes)
->warning()
->send();
throw new Halt();
}
}
public function creating(Expediente $expediente): void
{
$cuentaIntervinientes= $expediente->intervinientes->count();
$cuentaIntervinientesFacturables= $expediente->intervinientes->where('facturable',true)->count();
dd($cuentaIntervinientesFacturables, $cuentaIntervinientes);
if ($cuentaIntervinientesFacturables == $cuentaIntervinientes && $cuentaIntervinientes == 1){
//
} elseif ($cuentaIntervinientesFacturables == 0){
...
throw new Halt();
} elseif ($cuentaIntervinientesFacturables > 1 && $cuentaIntervinientesFacturables < $cuentaIntervinientes){
Notification::make()
->title('No todos los intervinientes son facturables. O todos o sólo uno')
->body('El expediente ' . $expediente->numExp . ' tiene ' . $cuentaIntervinientesFacturables . ' intervinientes facturables de ' . $cuentaIntervinientes)
->warning()
->send();
throw new Halt();
}
}
Any ideas of how I can validate repeaters counts and fields attributes inside the repeaters??? Thanks.
4 replies
FFilament
Created by Albert Lens on 3/6/2024 in #❓┊help
Missing New panel resources - links don't appear on sidebar - 404-Not found
Hello. I have been developing an app since the beginning of February and everthing was Ok. I have been creating 11 new resources and everytime their appeared on the sidebar menu. Today I have created two new resources and no links appear. If I manually type the url => http://127.0.0.1:8000/facturas it works perfectly. Even the links to http://127.0.0.1:8000/facturas/create and http://127.0.0.1:8000/facturas/1/edit But I cannot see the links to the two new resources. I have run:
composer update
php artisan cache:clear
php artisan optimize
php artisan view:clear
composer update
php artisan cache:clear
php artisan optimize
php artisan view:clear
But those two new links don't appear. I have no Policies created yet. Any ideas of what can be happening. I'm really puzzled.
17 replies
FFilament
Created by Albert Lens on 3/2/2024 in #❓┊help
How to reuse functions using services
Hello. I have made a function that I need to call from two different observers, and both in the created and update methods (I have to call it 4 times). I have tried to have one only function in an functions file and call it from the 4 different places, but I have not succeded. It is just a 10 line function, but there must be a better way to do this either than repeating the code 4 times. Any ideas of how to call a function which is in an external FUNCTIONS CUSTOM FILE from inside the observers? I understand that inside the same Observer I can use: $this->nameOfFunction() But how to call that from an outer file?
4 replies
FFilament
Created by Albert Lens on 2/29/2024 in #❓┊help
New custom login page not working according to documentation. Please help
Sure I am forgetting something obvious but cannot see what. I want to create a completely new login page form, so I have done this: 1.- Create a new page and blade view with ==> php artisan make:filament-page Auth/Login 2. - Changed the Login class like this:
use Filament\Pages\Auth\Login as FilamentLogin;

class Login extends FilamentLogin
{
protected static ?string $navigationIcon = 'heroicon-o-document-text';

protected static string $view = 'filament.pages.auth.login';
}
use Filament\Pages\Auth\Login as FilamentLogin;

class Login extends FilamentLogin
{
protected static ?string $navigationIcon = 'heroicon-o-document-text';

protected static string $view = 'filament.pages.auth.login';
}
3. - In AdminPanelProvider changed the ->login() for this => ->login(Login::class) and imported the class with:
use Filament\Pages\Auth\Login;
use Filament\Pages\Auth\Login;
But I can see no changes at all. I have added some text for testing in my view located at: resources\views\filament\pages\auth\login.blade.php Any ideas of what I am doing wrong?? I am using Filament v3.2.41 Thank you very much.
13 replies
FFilament
Created by Albert Lens on 2/27/2024 in #❓┊help
getFormActions / getCreateFormAction - Need to customize the save button to add more functionality
I have a resource in which I need to change the SAVE button by a new one which saves and also adds some function that I have prepared. How can I achieve this, please? I have tried adding this function to the CreateResource.php:
protected function getFormActions(): array
{
return [
$this->getCreateFormAction()->label('Crear traspaso contable')->color('primary'),
];
}
protected function getFormActions(): array
{
return [
$this->getCreateFormAction()->label('Crear traspaso contable')->color('primary'),
];
}
But I do not know how to: - Add my special function to that button (I want it to add the record to the table and do other things as well) Any ideas, please? I have also tried using an observer, which works fine, but then the problem is knowing how to: - change or delete the notification typical message of "created", because my other function also gives a message and one is shown covering the other. Tks.
4 replies
FFilament
Created by Albert Lens on 2/24/2024 in #❓┊help
Opening URLs from notification actions thows error ==> Route [pagos.index] not defined.
Hello. I have an action in a notification which I want to take the user to a resource index page. The resource is called pagos. I have used the official documentation in: https://filamentphp.com/docs/3.x/notifications/sending-notifications#opening-urls-from-notification-actions and only changed route('posts.show') for route('pagos.index') And it thows the same error. I have tried with 'admin.pagos.index', 'pagos', 'admin.pagos', tried in singular pago but I cannot achieve it. Any ideas, please: My code:
Action::make('ir a contabilidad')
->button()
->url(route('pagos.index'), shouldOpenInNewTab: true)
Action::make('ir a contabilidad')
->button()
->url(route('pagos.index'), shouldOpenInNewTab: true)
15 replies
FFilament
Created by Albert Lens on 2/23/2024 in #❓┊help
How to keep app global footer stuck at the bottom
No description
20 replies
FFilament
Created by Albert Lens on 2/23/2024 in #❓┊help
function in getOptionLabelFromRecordUsing() not working - Relationship of a Relationship
I need help, please. This is my Select:
Select::make('interviniente_id')
->relationship('interviniente', 'id')
->options(fn (Get $get): Collection => Interviniente::query()
->where('expediente_id', $get('expediente_id'))
->pluck('interviniente_id', 'id'))
->getOptionLabelFromRecordUsing(function ($value): ?string {
$persona = Persona::find($value);
return $persona->nombreCompleto;
})
->label(__('Interviniente'))
->preload()
->searchable(),
Select::make('interviniente_id')
->relationship('interviniente', 'id')
->options(fn (Get $get): Collection => Interviniente::query()
->where('expediente_id', $get('expediente_id'))
->pluck('interviniente_id', 'id'))
->getOptionLabelFromRecordUsing(function ($value): ?string {
$persona = Persona::find($value);
return $persona->nombreCompleto;
})
->label(__('Interviniente'))
->preload()
->searchable(),
It is showing the values for the field in the pluck('interviniente_id') but it is not showing the $persona->nombreCompleto. In the dropdown I see ids corresponding with "Persona" model ids (which is OK), so I only need to get those ids it is showing and replace them by the names or names and surnames of the persona model. No matter what I put in the getOptionLabelFromRecordUsing function, it always shows the same. I have also tried with getOptionLabelsUsing and nothing works. My relationships are MODEL_01 belongsTo MODEL_02 which also belongsTo MODEL_03, so how can I put the name of the field I need to retrieve? MODEL_01->MODEL_02->MODEL_03->fieldName or MODEL_01.MODEL_02.MODEL_03.fieldName ??? Nothing is working for me in that Select. Any help will be highly appreciated. Many thanks.
2 replies
FFilament
Created by Albert Lens on 2/16/2024 in #❓┊help
Mutate Data before Create (calculated column)
Hello. I need to calculate a column with series & id. The fields are Id, Series, NumExp and I need numExp to be equal to SERIES-ID If series is ABC and id is 20, I need numExp to be ABC20 I have tried this mutateFormDataBeforeCreate but it is not working.
protected function mutateFormDataBeforeCreate(array $data): array
{
$data['numExp'] = $data['serie'] . '-' . $data['id'];
return $data;
}
protected function mutateFormDataBeforeCreate(array $data): array
{
$data['numExp'] = $data['serie'] . '-' . $data['id'];
return $data;
}
Is there a boot method in the Model or something, please? Tks.
9 replies
FFilament
Created by Albert Lens on 10/5/2023 in #❓┊help
Need Notifications to be centered and bigger. Getting error doing what docs say.
Hello. I need to change the look and position of the notifications saying: Created. Deleted. Saved correctly. I have followed the official docs here : https://filamentphp.com/docs/2.x/notifications/customizing-notifications I have put this code in app\Providers\AppServiceProvider.php
public function boot(): void
{
Notification::configureUsing(function (Notification $notification): void {
$notification->view('notifications.notification');
});
}
public function boot(): void
{
Notification::configureUsing(function (Notification $notification): void {
$notification->view('notifications.notification');
});
}
I have also created the blade view file at resources\views\notifications\notification.blade.php
<x-notifications::notification
:notification="$notification"
class="flex w-80 rounded-lg transition duration-200"
x-transition:enter-start="opacity-0"
x-transition:leave-end="opacity-0"
>
<h4>
{{ $getTitle() }}
</h4>

<p>
{{ $getDate() }}
</p>

<p>
{{ $getBody() }}
</p>

<span x-on:click="close">
Close
</span>
</x-notifications::notification>
<x-notifications::notification
:notification="$notification"
class="flex w-80 rounded-lg transition duration-200"
x-transition:enter-start="opacity-0"
x-transition:leave-end="opacity-0"
>
<h4>
{{ $getTitle() }}
</h4>

<p>
{{ $getDate() }}
</p>

<p>
{{ $getBody() }}
</p>

<span x-on:click="close">
Close
</span>
</x-notifications::notification>
But I am getting an error: Unable to locate a class or view for component [notifications::notification]. It takes quite a few seconds thinking before thowing that error. Any ideas of what might be happening or what I am doing wrong. This is the first time I need to customize the notifications duration, size, etc. Tks.
2 replies
FFilament
Created by Albert Lens on 10/5/2023 in #❓┊help
SelectFilter for multiple values in Json in field NOT WORKING
Hello. I have a field called TAGS where user can select multiple. I casted in the model:
protected $casts = [
'tags' => 'array',
];
protected $casts = [
'tags' => 'array',
];
And field is type: longText and stores in JSON like this: ["registros","otros"] when user selected those two values. I am trying the SelectFilter like this:
SelectFilter::make('tags')
->multiple()
->options([
'registros' => 'registros',
'plusvalías' => 'plusvalías',
'otros' => 'otros',
]),
SelectFilter::make('tags')
->multiple()
->options([
'registros' => 'registros',
'plusvalías' => 'plusvalías',
'otros' => 'otros',
]),
And nothing thows an error, and I can select one or more of those options, but NO DATA IS RETRIEVED. As it was a simple field, I did not create a pivot table or relation for this. Any ideas of how I can customize my filter to work?? Something like CONTAINS or WhereIn ? Thank you very much.
5 replies
FFilament
Created by Albert Lens on 10/4/2023 in #❓┊help
All media (pdfs) table and how to make an open and download buttons for each record (for each pdf)
Hello. My users add several pdfs in several pages and now I want to make a resource for ALL PDFS, where every record is one only PDF. I already have that, coming from the table with name "media", but I cannot add a link or button to open the file in new tab and and another one for download. I am using Spatie Media Library but cannot find the right help for this. I really have all the information I need in that file called "media" I have tried this
TextColumn::make('name')
->label(__('name'))
->searchable()
->url(function (Get $get) {
$path=storage_path();
$ModelId= ($get('model_id')) ?? $get('model_id');
$name=($get('file_name')) ?? $get('file_name');
return $path . '/' . $ModelId . '/' . $name;
})
->openUrlInNewTab()
->sortable(),
TextColumn::make('name')
->label(__('name'))
->searchable()
->url(function (Get $get) {
$path=storage_path();
$ModelId= ($get('model_id')) ?? $get('model_id');
$name=($get('file_name')) ?? $get('file_name');
return $path . '/' . $ModelId . '/' . $name;
})
->openUrlInNewTab()
->sortable(),
but I get the error: Typed property Filament\Forms\Components\Component::$container must not be accessed before initialization for the first line with $get I have also tried an Action button like this:
Tables\Actions\Action::make(
__('Download'),
function (Get $get, Media $record) {
$path=storage_path();
$ModelId= ($get('model_id')) ?? $get('model_id');
$name=($get('file_name')) ?? $get('file_name');
return $path . '/' . $ModelId . '/' . $name;
}
)->icon('heroicon-o-arrow-down-tray')
Tables\Actions\Action::make(
__('Download'),
function (Get $get, Media $record) {
$path=storage_path();
$ModelId= ($get('model_id')) ?? $get('model_id');
$name=($get('file_name')) ?? $get('file_name');
return $path . '/' . $ModelId . '/' . $name;
}
)->icon('heroicon-o-arrow-down-tray')
but nothing seems to happen. Could anybody please give me hint of the right approach for this? Thanks a lot.
5 replies
FFilament
Created by Albert Lens on 9/30/2023 in #❓┊help
FileUpload working perfectly locally but in production server throws 404 only when retrieving file
No description
7 replies
FFilament
Created by Albert Lens on 9/27/2023 in #❓┊help
Approach pivot or relationship please?
Hello. I need help to study the right approach, please. I have a dossier model for inheritance records (to introduce all the data of an inheritance action) which has a hasMany relationship with interveners (people who will inherit somehing) and aso a hasMany relationship with goods (things to be inherited). I have already done that and I can add many interveners and many goods with a repeater in each case and saving the records in the relational tables. Now I have to let the user match every intervener with every good to give a percentage of inherit. My first idea was this: Intervener_id - Goods_id - Percentage 1 - 1 - 0% 1 - 2 - 75% 2 - 2 - 25% 3 - 1 - 100% Would you recommenda pivot table or maybe a different relationship type? I would like to have all x all fields in a kind of table, I mean, all goods in columns and all interveners in rows and every match point should have a percentage, considering many can be zero and maximum sum of percentages of a goods id to inherit is 100%. I will be very grateful to hear any ideas from you, people, on the best approach. Tks.
5 replies