ericmp
ericmp
FFilament
Created by ericmp on 11/8/2024 in #❓┊help
How to make all tables have same options for pagination?
Im not using admin panel, only tables pkg. How to make all tables have same options for pagination? I dont want to define it for all tables, i want to define it only in some place and then it applies to all tables of the project. How?
6 replies
FFilament
Created by ericmp on 11/7/2024 in #❓┊help
How to configure reverb with filament?
i want to be able to chat in admin panel. i installed laravel broadcasting and reverb I, following this tutorial https://laraveldaily.com/post/configure-laravel-reverb-filament-broadcasting, did: php artisan vendor:publish --tag=filament-config but now i have this:
'broadcasting' => [

// 'echo' => [
// 'broadcaster' => 'pusher',
// 'key' => env('VITE_PUSHER_APP_KEY'),
// 'cluster' => env('VITE_PUSHER_APP_CLUSTER'),
// 'wsHost' => env('VITE_PUSHER_HOST'),
// 'wsPort' => env('VITE_PUSHER_PORT'),
// 'wssPort' => env('VITE_PUSHER_PORT'),
// 'authEndpoint' => '/broadcasting/auth',
// 'disableStats' => true,
// 'encrypted' => true,
// 'forceTLS' => true,
// ],

],
'broadcasting' => [

// 'echo' => [
// 'broadcaster' => 'pusher',
// 'key' => env('VITE_PUSHER_APP_KEY'),
// 'cluster' => env('VITE_PUSHER_APP_CLUSTER'),
// 'wsHost' => env('VITE_PUSHER_HOST'),
// 'wsPort' => env('VITE_PUSHER_PORT'),
// 'wssPort' => env('VITE_PUSHER_PORT'),
// 'authEndpoint' => '/broadcasting/auth',
// 'disableStats' => true,
// 'encrypted' => true,
// 'forceTLS' => true,
// ],

],
but i dont use pusher, but reverb idk how to make it work, i tried:
'broadcasting' => [

'echo' => [
'broadcaster' => 'reverb',
'key' => env('VITE_REVERB_APP_KEY'),
'cluster' => env('VITE_REVERB_APP_CLUSTER'),
'wsHost' => env('VITE_REVERB_HOST'),
'wsPort' => env('VITE_REVERB_PORT'),
'wssPort' => env('VITE_REVERB_PORT'),
'authEndpoint' => '/broadcasting/auth',
'disableStats' => true,
'encrypted' => true,
'forceTLS' => true,
],

],
'broadcasting' => [

'echo' => [
'broadcaster' => 'reverb',
'key' => env('VITE_REVERB_APP_KEY'),
'cluster' => env('VITE_REVERB_APP_CLUSTER'),
'wsHost' => env('VITE_REVERB_HOST'),
'wsPort' => env('VITE_REVERB_PORT'),
'wssPort' => env('VITE_REVERB_PORT'),
'authEndpoint' => '/broadcasting/auth',
'disableStats' => true,
'encrypted' => true,
'forceTLS' => true,
],

],
then i do npm run build but i always get in console dev tools:
data
:
"{\"code\":4001,\"message\":\"Application does not exist\"}"
event
:
"pusher:error"
data
:
"{\"code\":4001,\"message\":\"Application does not exist\"}"
event
:
"pusher:error"
131 replies
FFilament
Created by ericmp on 11/7/2024 in #❓┊help
How to add header text for widget groups
I have a filament admin dashboard with some stats widgets: stat 1 --- stat2 --- stat3 --- stat 4 stat 5 --- stat6 --- stat7 --- stat 8 i want to separate them somehow and add a header on top of them, something like: general data: stat 1 --- stat2 --- stat3 --- stat 4 storage data: stat 5 --- stat6 --- stat7 --- stat 8 how would u do it? is possible with filament3? so far i managed to create 2 different widgets. the first one is the general data one, and the other one is the storage data one. so yeah, they are separated, but i need to add a header for each.
21 replies
FFilament
Created by ericmp on 11/4/2024 in #❓┊help
How to set tooltip on table header?
No description
19 replies
FFilament
Created by ericmp on 11/4/2024 in #❓┊help
Add maxlength to 255 chars on TextInput by default
For all my TextInput fields, I want to set a default maximum length of 255 characters, which is the commonly used VARCHAR length for database fields. I tried implementing this in app/Providers/AppServiceProvider.php:
TextInput::configureUsing(function (TextInput $input): void {
$input->maxLength(255);
});
TextInput::configureUsing(function (TextInput $input): void {
$input->maxLength(255);
});
However, I encountered an issue: if the TextInput is numeric or decimal, validation fails when the number exceeds 255. So, I attempted to conditionally apply the maxLength only if the input is not numeric or decimal:
TextInput::configureUsing(function (TextInput $input): void {
$inputMode = $input->getInputMode();

if ($inputMode !== 'numeric' && $inputMode !== 'decimal') {
$input->maxLength(255);
}
});
TextInput::configureUsing(function (TextInput $input): void {
$inputMode = $input->getInputMode();

if ($inputMode !== 'numeric' && $inputMode !== 'decimal') {
$input->maxLength(255);
}
});
But this approach doesn’t work because configureUsing is called before the component is used in the code, so inputMode is always empty. What should i do?
7 replies
FFilament
Created by ericmp on 11/1/2024 in #❓┊help
Keep table filters on url on relation manager
Id like to keep the table filters on url on relation manager. any ideas?
12 replies
FFilament
Created by ericmp on 10/30/2024 in #❓┊help
Filament ResetPassword notification - set locale correctly
i do:
app()->setLocale('ca');

$user = User::query()->where('email', '[email protected]')->first();

$token = \Illuminate\Support\Facades\Password::getRepository()->create($user);

$notification = new \Filament\Notifications\Auth\ResetPassword($token);
$notification->url = \Filament\Facades\Filament::getResetPasswordUrl($token, $user);

$user->notify($notification);
app()->setLocale('ca');

$user = User::query()->where('email', '[email protected]')->first();

$token = \Illuminate\Support\Facades\Password::getRepository()->create($user);

$notification = new \Filament\Notifications\Auth\ResetPassword($token);
$notification->url = \Filament\Facades\Filament::getResetPasswordUrl($token, $user);

$user->notify($notification);
the email i get is in english. why? im setting the app locale in catalan before sending the notification. why is sent in english? then i saw that in my env i have:
APP_LOCALE=en
APP_LOCALE=en
and if i change the env to:
APP_LOCALE=ca
APP_LOCALE=ca
and i get the email in catalan. but i dont want to change the APP_LOCALE i want the notification to be sent in the language i set before the notification is sent. how to achieve it? i thought doing app()->setLocale('ca') would do the trick, but seems is being ignored
5 replies
FFilament
Created by ericmp on 10/25/2024 in #❓┊help
Sort table by random order
In my songs table, i want to add a filter to let the user choose to order the records randomly:
Tables\Filters\Filter::make('in_random_order')->query(fn (Builder $query): Builder => $query->inRandomOrder())
Tables\Filters\Filter::make('in_random_order')->query(fn (Builder $query): Builder => $query->inRandomOrder())
but if i check it or not, the results are the same. what could be happening? how can i make it to work?
15 replies
FFilament
Created by ericmp on 10/15/2024 in #❓┊help
How To Apply `->imageEditor` on FileUpload v2?
I want the user to be able to use the image editor when uploading an image. But in v2 is not available. What would u do to achieve to let use the image editor? Update to v3? Or is there a way i dont know that this may be achieved in v2? like somehow creating a custom component like v3? but im not sure if that can be done.
Forms\Components\SpatieMediaLibraryFileUpload::make('title')
->avatar()
->maxSize(1024)
->imageEditor() // not available on v2
Forms\Components\SpatieMediaLibraryFileUpload::make('title')
->avatar()
->maxSize(1024)
->imageEditor() // not available on v2
11 replies
FFilament
Created by ericmp on 10/2/2024 in #❓┊help
How to Check Unique Field Names Across Sections in Nested Repeater?
The user is filling a form which creates this structure (an array of sections containing fields):
[
{
"name": "Section 1",
"fields": [
{
"name": "Field 1"
},
{
"name": "Field 2"
}
]
},
{
"name": "Section 1",
"fields": [
{
"name": "Field 1"
},
{
"name": "Field 2"
}
]
}
]
[
{
"name": "Section 1",
"fields": [
{
"name": "Field 1"
},
{
"name": "Field 2"
}
]
},
{
"name": "Section 1",
"fields": [
{
"name": "Field 1"
},
{
"name": "Field 2"
}
]
}
]
The problem is that i want the names to be unique. For the sections, is easy:
Forms\Components\Repeater::make('sections')
->schema([
Forms\Components\TextInput::make('name')
->distinct()
Forms\Components\Repeater::make('sections')
->schema([
Forms\Components\TextInput::make('name')
->distinct()
But then, for the fields: I don't know how to specify that I want them to be unique for the current section but also in other sections
Forms\Components\Repeater::make('sections')
->schema([
Forms\Components\TextInput::make('name')
->distinct()
->schema([
Forms\Components\Repeater::make('fields')
Forms\Components\TextInput::make('name')
->distinct() // how to specify that must be distinct in all sections, not only current one?
Forms\Components\Repeater::make('sections')
->schema([
Forms\Components\TextInput::make('name')
->distinct()
->schema([
Forms\Components\Repeater::make('fields')
Forms\Components\TextInput::make('name')
->distinct() // how to specify that must be distinct in all sections, not only current one?
What would u do?
3 replies
FFilament
Created by ericmp on 10/1/2024 in #❓┊help
How to add description into ImageColumn?
In the table I'm building, I want to show the image, and also a description. How to achieve it?
12 replies
FFilament
Created by ericmp on 9/20/2024 in #❓┊help
File upload component not validating correctly
No description
12 replies
FFilament
Created by ericmp on 8/31/2024 in #❓┊help
Convert model method to eloquent relationship
imagine this scenario tables:
Schema::create('users', function (Blueprint $table) {
$table->id();
$table->foreignIdFor(Task::class)->constrained();
});

Schema::create('tasks', function (Blueprint $table) {
$table->id();
});
Schema::create('users', function (Blueprint $table) {
$table->id();
$table->foreignIdFor(Task::class)->constrained();
});

Schema::create('tasks', function (Blueprint $table) {
$table->id();
});
eloquent relations:
class User extends Authenticatable
{
public function tasks(): BelongsToMany
{
return $this->belongsToMany(Task::class);
}
}

class Task extends Model
{
public function users(): HasMany
{
return $this->hasMany(User::class);
}

public function latestUser(): HasOne
{
return $this->hasOne(User::class)->latestOfMany();
}

public function oldestUser(): HasOne
{
return $this->hasOne(User::class)->oldestOfMany();
}
}
class User extends Authenticatable
{
public function tasks(): BelongsToMany
{
return $this->belongsToMany(Task::class);
}
}

class Task extends Model
{
public function users(): HasMany
{
return $this->hasMany(User::class);
}

public function latestUser(): HasOne
{
return $this->hasOne(User::class)->latestOfMany();
}

public function oldestUser(): HasOne
{
return $this->hasOne(User::class)->oldestOfMany();
}
}
right now, using only eloquent relations, i can know which is the latest and also which is the oldest user linked to the task. this is how it would look like the task model but wrong for this case, since they return ?User, but as i said, i need the methods to return eloquent relationships:
class Task extends Model
{
public function users(): HasMany
{
return $this->hasMany(User::class);
}

public function latestUser(): ?User
{
return $this->users()->orderBy('users.created_at', 'desc')->orderBy('users.id', 'desc')->first();
}

public function oldestUser(): ?User
{
return $this->users()->orderBy('users.created_at', 'asc')->orderBy('users.id', 'asc')->first();
}
}
class Task extends Model
{
public function users(): HasMany
{
return $this->hasMany(User::class);
}

public function latestUser(): ?User
{
return $this->users()->orderBy('users.created_at', 'desc')->orderBy('users.id', 'desc')->first();
}

public function oldestUser(): ?User
{
return $this->users()->orderBy('users.created_at', 'asc')->orderBy('users.id', 'asc')->first();
}
}
as you have noticed this is a has many relationship. and it works fine. but my question is how to translate this into a belongs to many relationship. as in the has many relationship case, for the belongs to many relationship i want: - to be able to retrieve task's users as an eloquent relationship - to be able to retrieve task's first user as an eloquent relationship - to be able to retrieve task's oldest user as an eloquent relationship
2 replies
FFilament
Created by ericmp on 8/28/2024 in #❓┊help
How to click all row and perform action in v2?
In v3 i do to make the users click the row and go to edit page, in v2 how can be achieved? i dont find it so far
->recordUrl(
fn (Model $record): string => Pages\EditCustomer::getUrl([$record->id]),
);
->recordUrl(
fn (Model $record): string => Pages\EditCustomer::getUrl([$record->id]),
);
3 replies
FFilament
Created by ericmp on 8/23/2024 in #❓┊help
Sometimes In Prod I Go To Login And Get Route Login Not Found
I have an admin panel provider, default filament stuff. Sometimes i get:
Symfony\Component\Routing\Exception\RouteNotFoundException: Route [login] not defined.
Symfony\Component\Routing\Exception\RouteNotFoundException: Route [login] not defined.
what to do?
4 replies
FFilament
Created by ericmp on 8/22/2024 in #❓┊help
Add Action For Table Group
Lets say i have a table of posts grouped by user_id
return $table
->groups([
Tables\Grouping\Group::make('user_id')
return $table
->groups([
Tables\Grouping\Group::make('user_id')
i want to add an action that will publish all posts of that user id. is there a way to add an action next to the row group? this way, id be able to publish the posts with a specific user_id at once for this specific example seems like a scoped bulk action for grouped records. but i dont mean this. imagine that the action will be something different, like updating a user field for whatever reason. is more like a header action, but for the group, which would return, in this case, the user_id, and then the developer, would do whatever has to be done with that id
9 replies
FFilament
Created by ericmp on 8/21/2024 in #❓┊help
How to disable Per page -> All
No description
6 replies
FFilament
Created by ericmp on 8/21/2024 in #❓┊help
How to set a Default Group With Descending Order By Default
In my table Im grouping. But i want the default order to be Desc instead of Asc. Is there a way to achieve it?
->groups([
Tables\Grouping\Group::make('game_reservation_id'),
])
->defaultGroup('game_reservation_id')
->groups([
Tables\Grouping\Group::make('game_reservation_id'),
])
->defaultGroup('game_reservation_id')
9 replies
FFilament
Created by ericmp on 8/9/2024 in #❓┊help
Multiple panels login issue
I have 2 panels /admin /client the user that im testing right now can access client, but not admin if i login in this route /client/login all works but if i try to login at /admin/login it says:
These credentials do not match our records.
These credentials do not match our records.
but this is wrong! the credentials DO match with our records, what happens is that the user cannot access that specific panel. i think the message should be clearer "you cannot access this panel or something like that", or if is on purpose like this, let at least the developer modify it somehow. can i modify it in a quick way, or is rather more complicated than it seems?? thanks in advance 🚀
9 replies
FFilament
Created by ericmp on 7/30/2024 in #❓┊help
Add Button Action To TextColumn
Problem: Right now, in the events table, my users want to click the row to go to the edit page of the record. But there is a problem. I have this TextColumn, which has a url. So if the user clicks the row, but not clicking the text, it opens the TextColumn url.
Tables\Columns\TextColumn::make('user.name')->url(function (Event $record): string {
return route('filament.admin.resources.users.edit', $record->user_id);
}),
Tables\Columns\TextColumn::make('user.name')->url(function (Event $record): string {
return route('filament.admin.resources.users.edit', $record->user_id);
}),
So is confusing, because they havent clicked the text of that TextColumn, therefore they don't want to navigate to that TextColumn url, they want to navigate to edit the specified record. What I want: So i want to instead of all the TextColumn space, create a button inside of it, so it is clear that if the user clicks the button will go where the button points to. otherwise, will go to edit the clicked row. What I tried: I tried to change the ->url for ->action:
Tables\Columns\TextColumn::make('user.name')->action(Tables\Actions\Action::make('view_user')->url(function (Event $record): string {
return route('filament.admin.resources.users.edit', $record->user_id);
})),
Tables\Columns\TextColumn::make('user.name')->action(Tables\Actions\Action::make('view_user')->url(function (Event $record): string {
return route('filament.admin.resources.users.edit', $record->user_id);
})),
But then, when i click it, it doesn't do anything. If i instead of ->url I put:
->action(function () {
dd('hi');
})
->action(function () {
dd('hi');
})
but is not visible Question: Is there a way, without creating a custom col, to add an action in the textcolumn, making it visible & also making the ->url action to work?
10 replies