Vitor
Vitor
FFilament
Created by Vitor on 8/5/2024 in #❓┊help
Custom CSV Importer file
No description
2 replies
FFilament
Created by Vitor on 8/4/2024 in #❓┊help
Custom page before list resource
I need to add a custom page before listing a resource. I tried something like this:
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'),
];
}
I want a page to select a factory and, after a factory is selected, list the products where the factory matches the selected one. What is the best approach to this?
13 replies
FFilament
Created by Vitor on 7/8/2024 in #❓┊help
Create a Team permissions with Shield
Hello guys! I'm using Filament 3 with Filament Shield and need to assign some models in teams for default permissions, like: I have a created user and this user in inside the Factory team. The factory team, by default, has permission to show all products and all sales. Has a way to do this?
5 replies
FFilament
Created by Vitor on 7/4/2024 in #❓┊help
SpatieMediaLibraryFileUpload in Custom Page
I have a customized page with a form, the media relationship is working fine, but the image is not displayed in the media input. ✅ APP_URL
4 replies
FFilament
Created by Vitor on 6/10/2024 in #❓┊help
(HELP) Multi permissions
Hello, Im developing a new system based in: Factories, Stores and a master admin. Factories can have multiple users; Stores can have multiple users; Admin can access all the resources. Basically, the factory can only access products and sales resources, but can i have a user relationed with the factory only with the product resource permission, and another with the sales only. Then, ill has a main permission in the factory and sub-permissions in the relationed users. Has a easy/practice way to implement this? Sorry if it was a little confusing
2 replies
FFilament
Created by Vitor on 6/5/2024 in #❓┊help
Get current model inside relationManager
Has a way to get the current model inside a RelationManager? My use case: I have a UserResource with a separate class called UserForm (with the form method to reuse); A AnotherResource with UserRelationManager, and inside the manager im using the same UserForm; A password field with ->visible(fn ($livewire) => $livewire instanceof CreateUser), but this dont works in a RelationManager.
5 replies
FFilament
Created by Vitor on 6/3/2024 in #❓┊help
Percentage and money mask
Has a easy way to implement percentage mask and money mask? Percentage example: 0 - 100% (can accept 99,25%); Money example: 3.550,75
2 replies
FFilament
Created by Vitor on 6/2/2024 in #❓┊help
Panels with some identical resources
Hello, I have a application with 3 different panels (admin, factory and storekeeper). Basically: Admin panel can access with the guard user and role admin; Factory panel can acess with guard factory; Storekeeper panel can acess with guard shop; The admin can access all the resources; The factory can access just products and sales resources, and there must be logic to search only for products related to the factory logged in. Storekeeper mantain the factory logic, acessing just the sales and products related to the storekeeper logged in. What would be the correct way to block these resources depending on the panel? Is there any way to have a variable in the resource (like $factoryCanAcess: bool), and inside each panel in discoverResources i check for the variable?
6 replies
FFilament
Created by Vitor on 5/28/2024 in #❓┊help
Custom resources directories
Has a way to create resources in custom folders? Im using a modular architeture, for example, i have 3 different models: base_path/modules/User, base_path/modules/Factory, base_path/modules/Car, And inside each module, i have a folder called filament/resources, and inside each resources i have the respective Resource. Is there any way to go through all the module folders and “attach” the resources? In filament v2, this provider this provider was working:
class RegisterResourcesServiceProvider extends FilamentPluginServiceProvider
{
public static string $name = 'registerResources';

public array $resources = [];

public function register()
{
parent::register();

$folders = File::directories(base_path('modules'));
foreach ($folders as $folder) {
$folderName = basename($folder);
$resourceFiles = glob($folder . '/pages/*Resource.php');

foreach ($resourceFiles as $resourceFile) {
$resourceClassName = basename($resourceFile, '.php');
$this->resources[] = 'System\\' . $folderName . '\\pages\\' . $resourceClassName;
}
}

$this->app->resolving('filament', function () {
Filament::registerResources($this->resources);
});
}
}
class RegisterResourcesServiceProvider extends FilamentPluginServiceProvider
{
public static string $name = 'registerResources';

public array $resources = [];

public function register()
{
parent::register();

$folders = File::directories(base_path('modules'));
foreach ($folders as $folder) {
$folderName = basename($folder);
$resourceFiles = glob($folder . '/pages/*Resource.php');

foreach ($resourceFiles as $resourceFile) {
$resourceClassName = basename($resourceFile, '.php');
$this->resources[] = 'System\\' . $folderName . '\\pages\\' . $resourceClassName;
}
}

$this->app->resolving('filament', function () {
Filament::registerResources($this->resources);
});
}
}
39 replies