Vitor
Vitor
FFilament
Created by Vitor on 8/4/2024 in #❓┊help
Custom page before list resource
I made this and it is working, but I’m not sure if it is the best way:
public static function getPages(): array
{
return [
'index' => FactoriesListPage::route('/factories'),
'list' => ListProducts::route('/factory/{factory}'),
'create' => CreateProduct::route('/create'),
'edit' => EditProduct::route('/{record}/edit'),
];
}
public static function getPages(): array
{
return [
'index' => FactoriesListPage::route('/factories'),
'list' => ListProducts::route('/factory/{factory}'),
'create' => CreateProduct::route('/create'),
'edit' => EditProduct::route('/{record}/edit'),
];
}
13 replies
FFilament
Created by Vitor on 8/4/2024 in #❓┊help
Custom page before list resource
The user has requested this custom page. And then, to create the product, I need to pass the same parameters from the selected factory so that the product is created based on it.
13 replies
FFilament
Created by Vitor on 8/4/2024 in #❓┊help
Custom page before list resource
Click on "Produtos" menu, go to a custom page to select the factory. After factory is selected, go to the matched list products table
13 replies
FFilament
Created by Vitor on 8/4/2024 in #❓┊help
Custom page before list resource
No description
13 replies
FFilament
Created by Vitor on 8/4/2024 in #❓┊help
Custom page before list resource
Basically, this is what i want:
13 replies
FFilament
Created by Vitor on 8/4/2024 in #❓┊help
Custom page before list resource
Thx for the reply, Dennis. It shouldn't be in the navigation. When clicking on the Products menu, I want to navigate to a custom page where a factory can be selected. After selecting a factory, I want to list all products that match the selected factory.
13 replies
FFilament
Created by Vitor on 7/8/2024 in #❓┊help
Create a Team permissions with Shield
Thx for the reply! Has another easy way to do this? Or package?
5 replies
FFilament
Created by Vitor on 7/4/2024 in #❓┊help
SpatieMediaLibraryFileUpload in Custom Page
SOLVED: Inside the SpatieMediaLibraryFileUpload.php, first we need to load('media') record and after getMedia.
$this->loadStateFromRelationshipsUsing(static function (SpatieMediaLibraryFileUpload $component, HasMedia $record): void {
/** @var Model&HasMedia $record */

// Changed here
$record->load('media')

$media = $record->getMedia($component->getCollection() ?? 'default')
->when(
$component->hasMediaFilter(),
fn (Collection $media) => $component->filterMedia($media)
)
->when(
!$component->isMultiple(),
fn (Collection $media): Collection => $media->take(1),
)
->mapWithKeys(function (Media $media): array {
$uuid = $media->getAttributeValue('uuid');

return [$uuid => $uuid];
})
->toArray();


$component->state($media);
});
$this->loadStateFromRelationshipsUsing(static function (SpatieMediaLibraryFileUpload $component, HasMedia $record): void {
/** @var Model&HasMedia $record */

// Changed here
$record->load('media')

$media = $record->getMedia($component->getCollection() ?? 'default')
->when(
$component->hasMediaFilter(),
fn (Collection $media) => $component->filterMedia($media)
)
->when(
!$component->isMultiple(),
fn (Collection $media): Collection => $media->take(1),
)
->mapWithKeys(function (Media $media): array {
$uuid = $media->getAttributeValue('uuid');

return [$uuid => $uuid];
})
->toArray();


$component->state($media);
});
To not change the package files directly, we can add the load in the mount() custom page method:
public function mount()
{
$this->model->load('media');
$this->form->fill($this->data);
}
public function mount()
{
$this->model->load('media');
$this->form->fill($this->data);
}
4 replies
FFilament
Created by Vitor on 6/5/2024 in #❓┊help
Get current model inside relationManager
Yeah, thats right. Thx Leandro and sorry for the "stupid" mistake of not seeing it before, I probably passed by it.
5 replies
FFilament
Created by Vitor on 6/2/2024 in #❓┊help
Panels with some identical resources
Filament shield is a good option?
6 replies
FFilament
Created by Vitor on 6/2/2024 in #❓┊help
Panels with some identical resources
The separate panels not "including" the unnecessary resources is safer than policies, or not?
6 replies
FFilament
Created by Vitor on 5/28/2024 in #❓┊help
Custom resources directories
Thanks bro ❤️
39 replies
FFilament
Created by Vitor on 5/28/2024 in #❓┊help
Custom resources directories
->discoverResources(in: base_path('modules'), for: 'System')
39 replies
FFilament
Created by Vitor on 5/28/2024 in #❓┊help
Custom resources directories
Ohhh, working fine
39 replies
FFilament
Created by Vitor on 5/28/2024 in #❓┊help
Custom resources directories
Yeah, but needs the for
39 replies
FFilament
Created by Vitor on 5/28/2024 in #❓┊help
Custom resources directories
My setup is basically: <BASE_PATH>/modules/<MODULE_NAME> Resources are in: <BASE_PATH>/modules/<MODULE>/filament/<MODULE>Resource Pages are in: <BASE_PATH>/modules/<MODULE>/filament/<MODULE>Resource/Pages I tried to do this: ->discoverResources(in: base_path('modules'), for: 'System\\Factory\\filament\\FactoryResource') ->discoverPages(in: base_path('modules'), for: 'System\\Factory\\filament\\FactoryResource\\Pages') But nothing happens
39 replies
FFilament
Created by Vitor on 5/28/2024 in #❓┊help
Custom resources directories
Ohh, sure
39 replies
FFilament
Created by Vitor on 5/28/2024 in #❓┊help
Custom resources directories
So if I have for example: <base_path>/modules/User; <base_path>/modules/Factory; <base_path>/modules/Car; Should I use: $panel->discoverResources("<base_path>/modules/User/resources", "namespace") $panel->discoverResources("<base_path>/modules/Factory/resources", "namespace") $panel->discoverResources("<base_path>/modules/User/resources", "namespace") This?
39 replies
FFilament
Created by Vitor on 5/28/2024 in #❓┊help
Custom resources directories
Sure, i get it. So do I have to specify it for each panel individually?
39 replies
FFilament
Created by Vitor on 5/28/2024 in #❓┊help
Custom resources directories
Sure, ill try this. Thanks for the suggestion
39 replies