Patrick
Patrick
FFilament
Created by Patrick on 6/7/2024 in #❓┊help
How can I hide NaviationItems in custom NavigationGroup based on user role
Okay...sorry it's not working with new login. I found the solution here: https://github.com/filamentphp/filament/issues/7288
11 replies
FFilament
Created by Patrick on 6/7/2024 in #❓┊help
How can I hide NaviationItems in custom NavigationGroup based on user role
Mhh but I am using a custom navigation, so ->navigationItems is not what I am using or? I am using your build in :getNavigationItems() on a resource which neither accepts a closure nor I have access to visible() or hide()
...ShippingDocumentResource::getNavigationItems()
...ShippingDocumentResource::getNavigationItems()
Custom Nav code part. So for example for Order Management I can hide the whole nav group by returning empty array if my auth check fails. But no clue how I can do it for single getNavigationItems()
->navigation(function (NavigationBuilder $builder): NavigationBuilder {
return $builder
->items(
Pages\Dashboard::getNavigationItems()
)
->groups([
NavigationGroup::make()
->label(__('Order Management'))
->items(auth()->user()->hasAnyRole(
...
)?[
NavigationItem::make(__('Orders'))
->url(fn():string => OrderResource\Pages\ListOrders::getUrl())
->icon('heroicon-o-rectangle-stack')
->isActiveWhen(fn (): bool => request()->routeIs(OrderResource\Pages\ListOrders::getRouteName())),
...ShippingDocumentResource::getNavigationItems(),
...ReturnableResource::getNavigationItems(),
]:[]),
...
->navigation(function (NavigationBuilder $builder): NavigationBuilder {
return $builder
->items(
Pages\Dashboard::getNavigationItems()
)
->groups([
NavigationGroup::make()
->label(__('Order Management'))
->items(auth()->user()->hasAnyRole(
...
)?[
NavigationItem::make(__('Orders'))
->url(fn():string => OrderResource\Pages\ListOrders::getUrl())
->icon('heroicon-o-rectangle-stack')
->isActiveWhen(fn (): bool => request()->routeIs(OrderResource\Pages\ListOrders::getRouteName())),
...ShippingDocumentResource::getNavigationItems(),
...ReturnableResource::getNavigationItems(),
]:[]),
...
11 replies
FFilament
Created by Patrick on 6/7/2024 in #❓┊help
How can I hide NaviationItems in custom NavigationGroup based on user role
Thanks! Sadly items() does not support a closure, so I will add items manually and do a check there 🙂
11 replies
FFilament
Created by Patrick on 6/7/2024 in #❓┊help
How can I hide NaviationItems in custom NavigationGroup based on user role
@Dennis Koch Thanks for your fast reply, I added a closure but the problem is more that visible() is not available on getNavigationItems(). Any ideas if there is way to solve it except adding all pages manually?
11 replies
FFilament
Created by Patrick on 5/27/2024 in #❓┊help
How to apply current filters to Columns using summaries?
Solution was provided by Kenneth Sese TextColumn::make('order_items_sum') ->sum(fn ($livewire) => ['orderItems' => function ($query) use ($livewire) { // dump the tableFilters to see the array structure so you can get the value. Probably want to use data_get() with wildcards) dd($livewire->tableFilters); return $query->where('your_table_filter', 'your_value'); }]),
3 replies
FFilament
Created by Patrick on 5/21/2024 in #❓┊help
Repeater Items: Disable already added items after form saved in edit mode
Thanks for your replies and sorry for the misleading question
9 replies
FFilament
Created by Patrick on 5/21/2024 in #❓┊help
Repeater Items: Disable already added items after form saved in edit mode
Sorry guys I think I did not explained my issue well. And the title was misleading. I have a RelationManager in my Tenant view for Orders. In Order Modal I can add OrderItems. What I was looking for is that already added items are disabled (only deletable) in Edit mode.
9 replies
FFilament
Created by Asmit Nepali on 5/23/2024 in #❓┊help
Is it possible to make select input invisible but send the default value with the form submit ?
Hi, do you have an example what you try to do? Why do u want to use a Select instead of Hidden or other Field with visible() and dehydrated() ?
7 replies
FFilament
Created by Patrick on 5/21/2024 in #❓┊help
Repeater Items: Disable already added items after form saved in edit mode
Hey @Rotorbit69 , Thanks for your reply. This is sadly not working for my case, what I did now is to wrap all fields in a grid and disabled() the grid based on the created_at hidden field.
9 replies
FFilament
Created by Patrick on 5/21/2024 in #❓┊help
Trigger form + relationship save method in custom action?
Thanks for your replies and help! It worked with $form->saveRelationships() in my custom action. I was missing to use($form) in my custom action and so had no access to saveRelationships() Thanks 🙂
4 replies
FFilament
Created by Patrick on 3/27/2024 in #❓┊help
Custom Action: validateOnly() for field in repeater
Nobody ever used validateOnly() ? 😛
3 replies
FFilament
Created by Emir Çelik on 3/25/2024 in #❓┊help
Relations..
Perhaps sth like: class ProductResource extends Resource { // ... protected static function form(Form $form): Form { return $form ->schema([ RichEditor::make('info') ->label('Product Info') ->required() ->reactive() ->afterStateUpdated(fn ($state, callable $set) => $set('productInfo.info', $state)), //<- info equals the field where you want to save the information ]); } // ... Then in your CreateProduct / EditProduct page you could use sth like: public static function mutateFormDataBeforeSave(array $data): array { if (isset($data['info'])) { $data['productInfo']['info'] = $data['info']; unset($data['info']); } return $data; } public static function mutateFormDataBeforeFill(array $data): array { if (isset($data['productInfo']['info'])) { $data['info'] = $data['productInfo']['info']; } return $data; } // ... }
11 replies
FFilament
Created by Emir Çelik on 3/25/2024 in #❓┊help
Relations..
Can u share code ? Is there a relationship between product and product_info ?
11 replies
FFilament
Created by Emir Çelik on 3/25/2024 in #❓┊help
Relations..
11 replies
FFilament
Created by Patrick on 3/12/2024 in #❓┊help
RelationManager shows "Class must be declared abstract or implement method 'getTableQueryForExport'"
Update solved it, but still no clue why it appeared randomly
9 replies
FFilament
Created by Patrick on 3/12/2024 in #❓┊help
RelationManager shows "Class must be declared abstract or implement method 'getTableQueryForExport'"
Thx @awcodes , I will try the update later
9 replies
FFilament
Created by Patrick on 3/12/2024 in #❓┊help
RelationManager shows "Class must be declared abstract or implement method 'getTableQueryForExport'"
Hey @Patrick1989 , Thanks for your reply. It's just my editor, but wasnt there before. Cant figure out what triggered it to appear
9 replies
FFilament
Created by Patrick on 2/20/2024 in #❓┊help
Best solution for dynamic Model attribute fields via Relationmanager
Hi @Clear , yes I got it working with my belongsToMany relationship. I still don't know if its the best solution but it works.
4 replies