ericmp
ericmp
FFilament
Created by ericmp on 12/8/2024 in #❓┊help
Cant make reverb to work inside admin panel
i have a project where i use livewire and laravel reverb. it works now, i tried to add a filament admin panel, and followed the docs to configure it properly. the problem is that i get a weird cluster error when i go to any page of the admin panel. afaik reverb doesnt use clusters!?
data
:
{code: 4001,…}
code
:
4001
message
:
"App key 0p107okcr7dfxpgb8x7j not in this cluster. Did you forget to specify the cluster?"
event
:
"pusher:error"
data
:
{code: 4001,…}
code
:
4001
message
:
"App key 0p107okcr7dfxpgb8x7j not in this cluster. Did you forget to specify the cluster?"
event
:
"pusher:error"
10 replies
FFilament
Created by ericmp on 12/4/2024 in #❓┊help
How to sort table by relationship?
i have item model: name, created_by_id i have user model so i have the relationship in the item model: user (which returns the user who created the item) in the items filament table im showing the item's user's created_at field now, i want to be able to sort the items by the user created_at field. so i want to sort them by the relationship how can i achieve it?
31 replies
FFilament
Created by ericmp on 11/22/2024 in #❓┊help
On sm, filament admin panel nav at the bottom of the screen
On sm screens, i want the filament admin panel navbar to be at the bottom of the screen, how would u achieve it?
14 replies
FFilament
Created by ericmp on 11/20/2024 in #❓┊help
How to configure breadcrumbs url on manage related records
No description
1 replies
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"
134 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