H4L1M
H4L1M
FFilament
Created by Will 🇬🇹 on 11/16/2024 in #❓┊help
Best practice for multiple dynamic properties
A resource is just a PHP class ! You can define an array variable And set it's value to your model each time the user changes the selected product with AfterstateUpdated
4 replies
FFilament
Created by H4L1M on 10/26/2024 in #❓┊help
Redirect to Profile On UsersRessource
I solved it by Overriding the authorizeAccess method on EditUser Class to check if the user is trying to Edit his own Record Before actually testing the Authorization part , then redirect to the EditProfilePage Class ( from Joaopaulolndev\FilamentEditProfile Plugin )
protected function authorizeAccess(): void
{
if (Auth::id() == $this->getRecord()->id) {
redirect()->intended(EditProfilePage::getUrl());
return;
}
abort_unless(static::getResource()::canEdit($this->getRecord()), 403);
}
protected function authorizeAccess(): void
{
if (Auth::id() == $this->getRecord()->id) {
redirect()->intended(EditProfilePage::getUrl());
return;
}
abort_unless(static::getResource()::canEdit($this->getRecord()), 403);
}
the other part is treated om the UserPolicy.php as @skyrowl refered
public function update(User $currentUser, User $targetUser): bool
{
return ($targetUser->hasRole('super_admin') || $currentUser->is($targetUser))?false:$currentUser->can('update_user');
}
public function update(User $currentUser, User $targetUser): bool
{
return ($targetUser->hasRole('super_admin') || $currentUser->is($targetUser))?false:$currentUser->can('update_user');
}
5 replies
FFilament
Created by H4L1M on 10/26/2024 in #❓┊help
Redirect to Profile On UsersRessource
On second thought, i think if someone is trying to be a hacker, he's not willing to go to his Profile.. I ll Stick to 403 But it would be nice to know how to do it
5 replies
FFilament
Created by codeartisan on 3/22/2024 in #❓┊help
Create default filter to be today
what if the user wants to see records from older dates
11 replies
FFilament
Created by nowak on 3/7/2024 in #❓┊help
How to hide a field in a 2 column layout and keep the space reserved
main section with 2 columns contains child section + field 3 child section with 2 columns and contains ur 2 fields
4 replies
FFilament
Created by WEBMAS on 3/4/2024 in #❓┊help
How to align content to the right?
schema([.......])->alignEnd()
8 replies
FFilament
Created by nowak on 3/4/2024 in #❓┊help
Show name instead of id in Select relationship field, upon record soft deletion.
hi; out of ur question ; whats $get('../../meal_type_id') ??? can u explain it pls
10 replies
FFilament
Created by H4L1M on 2/23/2024 in #❓┊help
Notification not working from Action Component
inside the action() method we can initiate a notification without the need to use successNotificationTitle() method {wich didnt work me}
->action(function (array $data) {
// your logic
Notification::make()
->success()
->title('test')
->body('test')
->send();
})
->action(function (array $data) {
// your logic
Notification::make()
->success()
->title('test')
->body('test')
->send();
})
4 replies
FFilament
Created by H4L1M on 2/22/2024 in #❓┊help
Save Action in a separate file
any other suggestions?
6 replies
FFilament
Created by H4L1M on 2/22/2024 in #❓┊help
Save Action in a separate file
@Leandro Ferreira Was just wondering and thought to add a question maybe some else will have the same ... , figured that I can add a method like userform() that returns an array in the related model "User" for example
public static function userForm() {
return [
textinput::make('email'),
.....
];
}
public static function userForm() {
return [
textinput::make('email'),
.....
];
}
then just call it like
User::userForm()
User::userForm()
wherever I want the form
6 replies
FFilament
Created by MajistraFila on 2/20/2024 in #❓┊help
[Solved] : Add Action to generate a word doc
inside your shema add
Forms\Components\Actions\Action::make('generateWordAction')
Forms\Components\Actions\Action::make('generateWordAction')
and follow https://filamentphp.com/docs/3.x/actions/trigger-button
6 replies
FFilament
Created by H4L1M on 2/17/2024 in #❓┊help
Form Component Placeholder
hello, the place holder accepts a method ->extraAttributes() the solution is to pass css class in an array like this
Forms\Components\Placeholder::make('User.ban')
->extraAttributes([
'class' => 'text-danger-600',
])
->content('red text')
Forms\Components\Placeholder::make('User.ban')
->extraAttributes([
'class' => 'text-danger-600',
])
->content('red text')
how ever theres only text-danger-600 compiled in the CSS app class , so am using
'sytle' => 'color: red'
'sytle' => 'color: red'
instead , did I forget somethig ? also the palceholder accepts HTML code ingection like this
->content(function ($record) {
$content = $record->isBanned()
? '<p style="color: red" class="font-bold">Banned</p>
<span class="block sm:inline">This user is Banned.</span>'
: '<p style="color: green" class="font-bold">Not Banned</p>
<span class="block sm:inline">This user currently has no active bans.</span>';
return new HtmlString($content);
})
->content(function ($record) {
$content = $record->isBanned()
? '<p style="color: red" class="font-bold">Banned</p>
<span class="block sm:inline">This user is Banned.</span>'
: '<p style="color: green" class="font-bold">Not Banned</p>
<span class="block sm:inline">This user currently has no active bans.</span>';
return new HtmlString($content);
})
as @Prosp30 motioned , thnks
5 replies