Pathros
Pathros
FFilament
Created by Zoltar on 6/25/2024 in #❓┊help
Email Verification in afterCreate() event
Leandro, this it works. Thanks. Additional help: 1) How do you translate the password reset form into another language? 2) After resetting the password, how do you pass the email into the input of the login page (when coming from the password reset form)?
36 replies
FFilament
Created by Pathros on 8/16/2024 in #❓┊help
resource navigation
Thanks!
//Referencias:
//https://filamentphp.com/docs/3.x/notifications/sending-notifications
protected function getSavedNotification(): ?Notification
{
return Notification::make()
->success()
->title('Fecha de término confirmada')
->body('Se ha guardado la fecha de término. Muchas gracias por su atención.')
->seconds(15)
;
}
//Referencias:
//https://filamentphp.com/docs/3.x/notifications/sending-notifications
protected function getSavedNotification(): ?Notification
{
return Notification::make()
->success()
->title('Fecha de término confirmada')
->body('Se ha guardado la fecha de término. Muchas gracias por su atención.')
->seconds(15)
;
}
4 replies
FFilament
Created by Pathros on 8/7/2024 in #❓┊help
For a custom filament page to edit a specific eloquent model, what is the URL of that page?
Thanks. Looks like I can get it from the route name list. The protected $slug property inside the custom page doesn't take effect but it does right from the getPages() array of the Resource.
10 replies
FFilament
Created by Glebka on 7/12/2024 in #❓┊help
Fill custom edit page form with data
How do I make that custom edit page appear in the navigation menu? I mean, if in the class setup I set:
class CustomEditResource extends Page implements HasForms
{
use InteractsWithForms;
class CustomEditResource extends Page implements HasForms
{
use InteractsWithForms;
I can see the page right at the navigation menu. However, if I try, just like in this example, which is what I really want to do (a custom page to edit a record):
class CustomEditResource extends EditRecord
{
use InteractsWithRecord;
class CustomEditResource extends EditRecord
{
use InteractsWithRecord;
the link to the page in the navigation, disappears. So how does this work? How do I set the link to that custom edit page? Could you please shed some light on this?
6 replies
FFilament
Created by Pathros on 8/7/2024 in #❓┊help
For a custom filament page to edit a specific eloquent model, what is the URL of that page?
I don't know what went wrong during the development phase, that I have tried to install a new fresh Laravel app with filament. As you suggest, I have added that page into the resource getPages()method:
public static function getPages(): array
{
return [
'index' => Pages\ListProyectos::route('/'),
'create' => Pages\CreateProyecto::route('/create'),
'view' => Pages\ViewProyecto::route('/{record}'),
'edit' => Pages\EditProyecto::route('/{record}/edit'),
'fechas-confirmar' => ConfirmarFechas::route('/{record}/fechas-confirmar'),//THIS ONE
];
}
public static function getPages(): array
{
return [
'index' => Pages\ListProyectos::route('/'),
'create' => Pages\CreateProyecto::route('/create'),
'view' => Pages\ViewProyecto::route('/{record}'),
'edit' => Pages\EditProyecto::route('/{record}/edit'),
'fechas-confirmar' => ConfirmarFechas::route('/{record}/fechas-confirmar'),//THIS ONE
];
}
and now I can see it registered inside the laravel routes: /.../projects/{record}/fechas-confirmar Then, how do I get the {record} in the custom page to fill the values in the form, so that the user can edit that record?
10 replies
FFilament
Created by Pathros on 8/7/2024 in #❓┊help
For a custom filament page to edit a specific eloquent model, what is the URL of that page?
well, I have found out:
php artisan route:list --name=filament
php artisan route:list --name=filament
But the page does not expect /{record}/ . How do I enable the edit page?
10 replies
FFilament
Created by ocram82 on 9/12/2023 in #❓┊help
Enum TextColumn badge() with label, icon and color
But I get the following error:
SubstitutionStatusEnum::from(): Argument #1 ($value) must be of type string|int, SubstitutionStatusEnum given
Well, now I have fixed it like so:
<?php
//...
public static function table(Table $table): Table
{
return $table
->columns([
//...
Tables\Columns\TextColumn::make('accepted_status')
->label('Stato')
->badge()
->icon(fn(Substitution $record) => $record->accepted_status->getIcon())
->color(fn(Substitution $record) => $record->accepted_status->getColor())
->formatStateUsing(fn(Substitution $record) => $record->accepted_status->getLabel())
->sortable()
,
<?php
//...
public static function table(Table $table): Table
{
return $table
->columns([
//...
Tables\Columns\TextColumn::make('accepted_status')
->label('Stato')
->badge()
->icon(fn(Substitution $record) => $record->accepted_status->getIcon())
->color(fn(Substitution $record) => $record->accepted_status->getColor())
->formatStateUsing(fn(Substitution $record) => $record->accepted_status->getLabel())
->sortable()
,
That did the trick for me
8 replies
FFilament
Created by Denxio on 5/2/2024 in #❓┊help
Private Image not showing
Thanks, @Dennis Koch @awcodes . I realized that using the column foto in both the database as a column name and in the filesystems.php config file was causing the problem. I discovered when I noticed that setting up the label for "fotos" was ignored in the resource table:
return $table
->columns([
Tables\Columns\ImageColumn::make('foto')
->disk('fotos')
->label('Fotografía') //IGNORED
,
return $table
->columns([
Tables\Columns\ImageColumn::make('foto')
->disk('fotos')
->label('Fotografía') //IGNORED
,
then I started changing the name to whatever and test the label()to see whether or not was ignored. So, finally it worked when I changed the word "foto" to something else:
Forms\Components\FileUpload::make('avatar')
->label('Fotografía')
->image()
->disk('avatares')
->storeFileNamesIn('avatares')

//....
return $table
->columns([
Tables\Columns\ImageColumn::make('avatar')
->disk('avatares')
->label('Fotografía') //no longer ignored
,
Forms\Components\FileUpload::make('avatar')
->label('Fotografía')
->image()
->disk('avatares')
->storeFileNamesIn('avatares')

//....
return $table
->columns([
Tables\Columns\ImageColumn::make('avatar')
->disk('avatares')
->label('Fotografía') //no longer ignored
,
and in filesystems.php
'avatares' => [
'driver' => 'local',
'root' => storage_path('app/path/to/avatares'),
'visibility' => 'private',
'url' => env('APP_URL').'/avatares',
],
'avatares' => [
'driver' => 'local',
'root' => storage_path('app/path/to/avatares'),
'visibility' => 'private',
'url' => env('APP_URL').'/avatares',
],
So, "private" visibility was not causing any problem. now it finally is working 🎉
17 replies
FFilament
Created by Denxio on 5/2/2024 in #❓┊help
Private Image not showing
The HMTL of the table looks like the following:
<!--[if BLOCK]><![endif]--> <a
href="https://app.test/administracion-76f0soRlv4+pCDgFjA15X-IIS/personal-academico-administrativo/1"
class="flex w-full disabled:pointer-events-none justify-start text-start"
>
<div
class="fi-ta-text grid w-full gap-y-1 px-3 py-4"
>
<!--[if BLOCK]><![endif]--> <!--[if BLOCK]><![endif]--><!--[if ENDBLOCK]><![endif]-->

<div
class="flex "
>
<!--[if BLOCK]><![endif]-->
<div
class="flex max-w-max"
style=""
>
<!--[if BLOCK]><![endif]--> <div
class="fi-ta-text-item inline-flex items-center gap-1.5 "
>
<!--[if BLOCK]><![endif]--><!--[if ENDBLOCK]><![endif]-->

<span
class="fi-ta-text-item-label text-sm leading-6 text-gray-950 dark:text-white "
style=""
>
foto_perfil__academico__f__20240518_133235image-9.png
</span>

<!--[if BLOCK]><![endif]--><!--[if ENDBLOCK]><![endif]-->
</div>
<!--[if ENDBLOCK]><![endif]-->
</div>
<!--[if ENDBLOCK]><![endif]-->
<!--[if ENDBLOCK]><![endif]-->

<!--[if BLOCK]><![endif]--><!--[if ENDBLOCK]><![endif]-->
</div>

<!--[if BLOCK]><![endif]--><!--[if ENDBLOCK]><![endif]-->
<!--[if ENDBLOCK]><![endif]-->
</div>

</a>
<!--[if BLOCK]><![endif]--> <a
href="https://app.test/administracion-76f0soRlv4+pCDgFjA15X-IIS/personal-academico-administrativo/1"
class="flex w-full disabled:pointer-events-none justify-start text-start"
>
<div
class="fi-ta-text grid w-full gap-y-1 px-3 py-4"
>
<!--[if BLOCK]><![endif]--> <!--[if BLOCK]><![endif]--><!--[if ENDBLOCK]><![endif]-->

<div
class="flex "
>
<!--[if BLOCK]><![endif]-->
<div
class="flex max-w-max"
style=""
>
<!--[if BLOCK]><![endif]--> <div
class="fi-ta-text-item inline-flex items-center gap-1.5 "
>
<!--[if BLOCK]><![endif]--><!--[if ENDBLOCK]><![endif]-->

<span
class="fi-ta-text-item-label text-sm leading-6 text-gray-950 dark:text-white "
style=""
>
foto_perfil__academico__f__20240518_133235image-9.png
</span>

<!--[if BLOCK]><![endif]--><!--[if ENDBLOCK]><![endif]-->
</div>
<!--[if ENDBLOCK]><![endif]-->
</div>
<!--[if ENDBLOCK]><![endif]-->
<!--[if ENDBLOCK]><![endif]-->

<!--[if BLOCK]><![endif]--><!--[if ENDBLOCK]><![endif]-->
</div>

<!--[if BLOCK]><![endif]--><!--[if ENDBLOCK]><![endif]-->
<!--[if ENDBLOCK]><![endif]-->
</div>

</a>
Any ideas?
17 replies
FFilament
Created by Denxio on 5/2/2024 in #❓┊help
Private Image not showing
What is strange is that I can see the image right in the form: However, in the table, I only see the name of the file, instead of the image itself: What I have tried is setting up a custom PhotoColumn.php:
<?php

namespace App\Tables\Columns\Sica\Academicos;

use Filament\Tables\Columns\Column;
use Filament\Tables\Columns\ImageColumn;
use Illuminate\Support\Facades\Storage;

class PhotoColumn extends Column
{
protected string $view = 'tables.columns.path.to.photo-column';
protected function getImageUrl(): ?string
{
$record = $this->getRecord();
$path = $this->getState();

if ($record && $path) {
return Storage::disk('fotos')->temporaryUrl($path, now()->addMinutes(5));
}

return null;
}
}
<?php

namespace App\Tables\Columns\Sica\Academicos;

use Filament\Tables\Columns\Column;
use Filament\Tables\Columns\ImageColumn;
use Illuminate\Support\Facades\Storage;

class PhotoColumn extends Column
{
protected string $view = 'tables.columns.path.to.photo-column';
protected function getImageUrl(): ?string
{
$record = $this->getRecord();
$path = $this->getState();

if ($record && $path) {
return Storage::disk('fotos')->temporaryUrl($path, now()->addMinutes(5));
}

return null;
}
}
that I use in the Resource table:
public static function table(Table $table): Table
{
return $table
->columns([
PhotoColumn::make('foto')
->label('Fotografía')
,
public static function table(Table $table): Table
{
return $table
->columns([
PhotoColumn::make('foto')
->label('Fotografía')
,
here's the view:
@props([
'state' => null,
])

@if ($state)
<img src="{{ $state }}" style="max-height: 100px;" alt="Image" />
@else
<span>No Image</span>
@endif
@props([
'state' => null,
])

@if ($state)
<img src="{{ $state }}" style="max-height: 100px;" alt="Image" />
@else
<span>No Image</span>
@endif
and I still see the exact same result: the image name, instead of the image itself. By the way, setting up a label doesn't work.
return $table
->columns([
Tables\Columns\ImageColumn::make('foto')
->label('Fotografía')
,
return $table
->columns([
Tables\Columns\ImageColumn::make('foto')
->label('Fotografía')
,
the label text "Fotografía" is not displayed, but "Foto" instead Any ideas how to fix this? How to make the images display?
17 replies
FFilament
Created by Denxio on 5/2/2024 in #❓┊help
Private Image not showing
hello! I have tried 'public' in the filesystems.php config and have got the same result. =( Then, how to set that controller up?
17 replies
FFilament
Created by Denxio on 5/2/2024 in #❓┊help
Private Image not showing
I also have the same problem in latest Filament v3 and Laravel v11. The ImageColumn() method is displaying the photo name, instead of the image itself. Here's my disk config at filesystems.php:
'photos' => [
'driver' => 'local',
'root' => storage_path('app/custom/staff/photos'),
'visibility' => 'private',//I also have tried with 'public' and doesn't work either
'url' => env('APP_URL').'/photos',
],
'photos' => [
'driver' => 'local',
'root' => storage_path('app/custom/staff/photos'),
'visibility' => 'private',//I also have tried with 'public' and doesn't work either
'url' => env('APP_URL').'/photos',
],
Here's the ImageColumn() method in the Resource:
public static function table(Table $table): Table
{
return $table
->columns([
Tables\Columns\ImageColumn::make('foto')//as in the DB column name
->label('Fotografía')
->disk('photos')
,
public static function table(Table $table): Table
{
return $table
->columns([
Tables\Columns\ImageColumn::make('foto')//as in the DB column name
->label('Fotografía')
->disk('photos')
,
That displays the picture file name, instead of the photo image itself. However, I can see the image right at the form:
Forms\Components\FileUpload::make('foto')// just like the db column name
->label('Fotografía')
->image()
->disk('photos')
->storeFileNamesIn('photos')
->openable()
->previewable()
->maxSize(2 * 1024)//2MB
->minFiles(0)
->maxFiles(1)
->placeholder('Imagen de perfil o avatar')
->columnSpanFull()
,
Forms\Components\FileUpload::make('foto')// just like the db column name
->label('Fotografía')
->image()
->disk('photos')
->storeFileNamesIn('photos')
->openable()
->previewable()
->maxSize(2 * 1024)//2MB
->minFiles(0)
->maxFiles(1)
->placeholder('Imagen de perfil o avatar')
->columnSpanFull()
,
What am I missing to make it display the image itself in the table, instead of the filename??? Any ideas?
17 replies