Meymink
Is this best practise?
Hi, i'm trying out something new and don't have much experience with Filament.
I'm trying to follow best practises and wonder whether i'm doing the following right?
Will i encounter problems ?
I have a resource called 'EmailAccountResource' and removed the 'createRecord' action to replace it with a custom page where Office365 accounts can be connected and added to the model.
So i created a custom page where i can generate a URL and add it to a custom action like this:
and
Or am i supposed to create a custom action like a 'create' action exists and handle these kind of things there?
So basically, when do i create a custom page and when do i create custom actions?
1 replies
Assign roles to a team rather than a user
Hello, i hope this is allowed here but im desperate for help as i've been struggling for days on this.
This is my first project and the first time i'm using the spatie permissions package.
I've read the documentation multiple times and i'm still confused and facing a problem.
I am working on a project with the following structure:
Teams (tenants)
Team members
Users
Roles
Permissions
Subscriptions
(Filament) panels:
Admin panel (for devs & admins)
App panel (can only be accessed through a 'public' team/tenant.)
All users have a personal team (a private team/tenant).
A personal team can only have roles and nothing more.
So i assign the Global Admin role to one's personal team and that's how he can access the admin panel.
In order to be able to use the app/software, one must be in a 'public' team so he or she can access the team resources and data in the app panel.
So app data (example, a social media account) is always linked to a team so that the entire team can manage (the social media account) data.
I have three types of roles:
Global roles (such as Global admin, Global developer, Global moderator)
Team member roles (Example, someone else besides the team owner should be able to invite and remove members)
Subscription roles (Subscriptions are linked to a team rather than a user.)
So basically the team should access certain features based on the package that the team has subscribed to.
Up until now i was able to assign roles to team members and was able to verify whether a user has access to a permission for the team/tenant using setPermissionTeamId.
But doing something like $team->can('use function') is impossible because the team cannot use 'can' it says.
How can i assign roles to the entire team rather than one team member?
I would love to use this package but is it possible within the structure im working on?
Or are there better aproaches/structures for the same goal?
Would love to get some advice on this.
20 replies
Get the resource form in custom action
Hi!
I've been researching and messing around with forms for a few days and hours now.
Researching filament package code and even plugins i still couldn't figure out how to use the form i created in my relationshipmanager in my custom action.
So i basically have a TeamRelationshipManager where i have created a form in.
Next i added a custom made action within the headeraction.
In my custom made action, i rewrote the form because i couldn't figure out how to use the form i created in the relationship manager.
Any ideas?
5 replies
Advice for code & structure
Hi!
I'm currently developing my first app using Filament. My experience primarily lies in working with Laravel for smaller applications within startups and companies, where I focused on automating processes.
Recently, I decided to create a SaaS application using Laravel and discovered Filament in my research. I've been experimenting with Filament and have started integrating it into my SaaS boilerplate, particularly for core user panel functions like teams, roles, permissions, plugins, user/admin panels, and payment methods.
I've completed the Teams feature and its corresponding views in the admin panel. However, I'm unsure if I'm utilizing Filament optimally and have some questions. I would appreciate insights from experienced programmers:
1. Is it advisable to use Filament for an entire project? I find it very useful and want to incorporate it fully into my product. Are there potential issues with this approach, such as handling payments?
2. Many developers seem to prefer custom Livewire components over resources for their models. Why is this?
3. In what situations should custom Livewire components be used instead of resources? Can you provide an example?
4. My TeamResource has 227 lines, including multiple functions like form, table, infolist, and some configurations. These seem like separate aspects of the same model, which makes me wonder if it's too much for one class. When should a class be split into smaller ones for cleaner code?
Or is this just the way how Filament should be used?
5 replies
Login page parameters
Hello everyone!
I've been struggling with something i'm trying to achieve and would like to ask someone to read my case and give me some advise.
Case
1. I have created my own 'Team' system and i'm working on team invitations.
2. Currently, users can receive emails in their inbox with a link to
https://xxxx.com/user/login?invitation=xxxxxxxxxxx
3. The login url/route leads to an extended class of Filament\Pages\Auth\Login
which i assigned in the UserPanelProvider in $panel->login(UserLogi::class)
4. I'm stuck at handling the extra 'invitation' parameter.
5. I may add/handle more parameters in the future for handling different kind of actions/requests.
My questions
1. How can access the 'invitation' and possibly other parameters in my UserLogin class?
2. Since i can't find any other similiar cases. Am i doing this all wrong?
What i tried
In order to understand what i tried, you might wanna check out my code below first.
1. In my public function form(Form $form)
or public function __construct()
when i do dd(request('invite')
i can see the value of the parameter.
2. But in my public function beforeAuthenticate()
it returns null
3. I've tried to set a parameter in my constructor but it gets set back to null when i'm in my public function authenticate()
My code
4 replies
Show users who are not in team
Hi, i'm trying to create a form which can be used to add members to a team.
I'm using a repeater to manage existing users using the following code:
Forms\Components\Repeater::make('teamUsers')
->relationship()
->simple(
Forms\Components\Select::make('user_id')
->placeholder('Select a user')
->relationship(
'user',
'name',
modifyQueryUsing: function (Builder $query) {}
)
->required()
->searchable(),
),
I'm using a repeater on TeamUser (pivot).
How can i only show users who are not in the team already?4 replies
allUsers error: Call to a member function getKey() on null
Hello everyone,
I've created my own team functionality.
In my TeamResource, i want to add a column in my table which shows the amount of members in a team including the owner.
I have these three functions in my Team model which are identical to both Jetstream and Filament Companies plugin team model:
/**
* Get the owner of the team.
*/
public function owner(): BelongsTo
{
return $this->belongsTo(\App\Models\User::class, 'user_id');
}
/**
* Get all the team's users including its owner.
*/
public function allUsers(): Collection
{
return $this->users->merge([$this->owner]);
}
/**
* Get all the users that belong to the team.
*/
public function users(): BelongsToMany
{
return $this->belongsToMany(\App\Models\User::class, \App\Models\TeamUser::class)
->withTimestamps();
}
And i'm using the following in my resource:
Tables\Columns\TextColumn::make('allUsers_count')
->searchable()
->sortable()
->counts('allUsers'),
The error i'm getting: Call to a member function getKey() on null
I've been trying things out for hours but can't seem to understand why this is happening.
In allUsers() when i try dd($this->users->merge([$this->owner]));
i see an empty array.
But when i do dd($this->users->merge($this->owner()-get()));
I get two results.
However i can't user get() because Filament does the query building in the resource.
Is there anyone who understands what is going wrong here?7 replies
[Spatie-Permissions] Possibilities of assigning roles to both teams and users
Hello everyone!
I have a simple question.
Is it possible to use spatie-permissions for both users and teams at the same time?
For example, i have an admin role which is meant to be assigned to users only.
But i also have roles which will be assigned based on subscriptions.
So role package_1 is only meant to be assigned to teams.
After reading https://spatie.be/docs/laravel-permission/v6/basic-usage/teams-permissions
I got confused because if teams = enabled in config, it is necessary to fill in the team column with either NULL or a team id.
Does this mean that with teams enabled, i can't assign roles to users anymore because it always has to be linked to a team?
8 replies
Few questions about use of Filament
Hi, I have three questions about using Filament and am looking for someone who has created SaaS with Filament who can answer my questions.
I want to start creating a SaaS template that I can use for various SaaS projects. This template includes the following features:
1. Admin panel
2. User panel (This is where the core functions of the SaaS are located.)
3. Teams/Multi-tenancy
4. Roles/permissions
5. Payment options and processing of actual transactions.
The questions I have regarding Filament are as follows:
1. Is Filament intended only for creating Admin Panels? Or can it also be used for the user panel where the transactions are conducted, but also where the core functions of the SaaS are located.
2. If Filament can be used for the user panel with the core SaaS functions, how scalable is it with Filament?
3. If Filament cannot be used for the user panel with the core SaaS functions, how do I use everything I've created within Filament? Like the multi-tenancy, roles, and permissions that are all created and managed within Filament. How would I, for example, use this in my custom user panel?
5 replies