F
Filament11mo ago
Oddman

How can you create a resource that is based off another model?

I currently have a resource called "User", which has a bunch of filters enabled. One of those filters, is called Role - and when the role of "Author" is checked, it only shows users with that role. Additionally, it enables/disables some functionality for users when viewing authors, such as showing how much they're owed for their content, articles they've published.etc. This is getting out of hand, as I'm having to do a lot of checks all over the place, and I think it would be better if I simply contextualised a new resource, based on the User model. However, I'm having some difficulties setting this up properly. Any suggestions or tips on how to do this "properly" ?
3 Replies
Tieme
Tieme11mo ago
You want to create multiple resources based on the user model with custome query's?
krekas
krekas11mo ago
you can access table from another resource. if you need that
karim charfaoui
karim charfaoui11mo ago
final class EmployeResource extends Resource
{
protected static ?string $model = User::class;

protected static ?string $slug = 'employees';
final class EmployeResource extends Resource
{
protected static ?string $model = User::class;

protected static ?string $slug = 'employees';
just create another resource with any name then change your $model and the $slug
Want results from more Discord servers?
Add your server