awcodes
awcodes
FFilament
Created by Bart - EffectConnect on 11/18/2024 in #❓┊help
Automatically delete Export files
Just create a scheduled task that grabs the files checks their dates and delete them if they are old enough.
6 replies
FFilament
Created by Jamie Cee on 11/18/2024 in #❓┊help
illegal offset type in tests
if it's something in the package then it's not a filament question. 🙂
27 replies
FFilament
Created by Jamie Cee on 11/18/2024 in #❓┊help
illegal offset type in tests
ah, don't know anything about the package. sorry. might get better support if you ask the question directly on that channel. #althinect-spatie-roles-permissions
27 replies
FFilament
Created by Jamie Cee on 11/18/2024 in #❓┊help
illegal offset type in tests
try using ->can() instead of ->checkPermissionTo(). I think that might be an internal method. The docs say to use ->can
27 replies
FFilament
Created by Jamie Cee on 11/18/2024 in #❓┊help
illegal offset type in tests
then in my tests i use loginAsUser(role: 'Pages', permission: 'page'); to login the user with the appropriate permissions and role. and it works.
27 replies
FFilament
Created by Jamie Cee on 11/18/2024 in #❓┊help
illegal offset type in tests
i'm using pest, but i have these helpers:
function loginAsUser(string $role, string $permission, ?User $user = null): User
{
$roleModel = Role::create(['name' => "Manage $role"]);
$view = Permission::create(['name' => "view $permission"]);
$create = Permission::create(['name' => "create $permission"]);
$update = Permission::create(['name' => "update $permission"]);
$delete = Permission::create(['name' => "delete $permission"]);

$roleModel->givePermissionTo([$view, $update, $create, $delete]);

$user = $user ?? User::factory()->create();
$user->assignRole("Manage $role");
actingAs($user);

return $user;
}

function createRole(string $role, string $permission): Role
{
$roleModel = Role::create(['name' => "Manage $role"]);
$view = Permission::create(['name' => "view $permission"]);
$create = Permission::create(['name' => "create $permission"]);
$update = Permission::create(['name' => "update $permission"]);
$delete = Permission::create(['name' => "delete $permission"]);

$roleModel->givePermissionTo([$view, $update, $create, $delete]);

return $roleModel;
}
function loginAsUser(string $role, string $permission, ?User $user = null): User
{
$roleModel = Role::create(['name' => "Manage $role"]);
$view = Permission::create(['name' => "view $permission"]);
$create = Permission::create(['name' => "create $permission"]);
$update = Permission::create(['name' => "update $permission"]);
$delete = Permission::create(['name' => "delete $permission"]);

$roleModel->givePermissionTo([$view, $update, $create, $delete]);

$user = $user ?? User::factory()->create();
$user->assignRole("Manage $role");
actingAs($user);

return $user;
}

function createRole(string $role, string $permission): Role
{
$roleModel = Role::create(['name' => "Manage $role"]);
$view = Permission::create(['name' => "view $permission"]);
$create = Permission::create(['name' => "create $permission"]);
$update = Permission::create(['name' => "update $permission"]);
$delete = Permission::create(['name' => "delete $permission"]);

$roleModel->givePermissionTo([$view, $update, $create, $delete]);

return $roleModel;
}
27 replies
FFilament
Created by Jamie Cee on 11/18/2024 in #❓┊help
illegal offset type in tests
do you have a repo you can share?
27 replies
FFilament
Created by Jamie Cee on 11/18/2024 in #❓┊help
illegal offset type in tests
when you seed the roles you also have to seed the permissions and assign the permissions to the roles if you want to use both
27 replies
FFilament
Created by Jamie Cee on 11/18/2024 in #❓┊help
illegal offset type in tests
Permissions and Roles are separate in Spatie's package
27 replies
FFilament
Created by Jamie Cee on 11/18/2024 in #❓┊help
illegal offset type in tests
Hm. Filament honors the policy and your policy is checking permissions not roles. But I would expect it to work with true.
27 replies
FFilament
Created by Jamie Cee on 11/18/2024 in #❓┊help
illegal offset type in tests
And what’s in the policy?
27 replies
FFilament
Created by Jamie Cee on 11/18/2024 in #❓┊help
illegal offset type in tests
Make sure you are seeding the roles and permissions too.
27 replies
FFilament
Created by Matthew on 11/15/2024 in #❓┊help
Plugin development: JS file net::ERR_ABORTED 404 (Not Found)
Registering plugin scripts will publish them to the public folder when someone installs your plugin. During development though you need to manually publish it anytime you make changes.
8 replies
FFilament
Created by Matthew on 11/15/2024 in #❓┊help
Plugin development: JS file net::ERR_ABORTED 404 (Not Found)
php artisan filament:assets
8 replies
FFilament
Created by prouse_ on 11/9/2024 in #❓┊help
Same field in all forms/resources
I would prefer opting in over opting out.
9 replies
FFilament
Created by prouse_ on 11/9/2024 in #❓┊help
Same field in all forms/resources
Fair, but you’re still going to have to merge in any other fields or columns even with overriding the methods you would have to merge with the parent anyway. In my head, including a custom form field and a custom table column is easier and more extendable than overriding backwards. Whatever works for you though. I could very well be missing the point.
9 replies
FFilament
Created by sadiqgoni13 on 11/14/2024 in #❓┊help
System Overheating due to Vite CSS
You won't be running npm run dev on the server. That should only be used in development. And with npm run build all the files will be built and just served as regular CSS and JS files. Also your server is going to be more powerful than your computer. Pretty sure you'll be ok in production. 🙂
5 replies
FFilament
Created by Matthew on 11/14/2024 in #❓┊help
FileUpload max size validation isnt working
You need to publish the livewire config and change its max size too.
3 replies
FFilament
Created by binaryfire on 11/10/2024 in #❓┊help
Open builder block picker in modal instead of dropdown
I’m sure.
6 replies
FFilament
Created by binaryfire on 11/10/2024 in #❓┊help
Open builder block picker in modal instead of dropdown
It should be possible. You can override the addAction on the builder. I think it would take some work though to wire it back up though. I don’t think it would be as simple as making the existing one a modal.
6 replies