JamesTechDude
Explore posts from serversTLCTuto's Laravel Corner
•Created by JamesTechDude on 8/20/2023 in #💡filament
Making tabs for edit page
Sadly I decided to go away from Filament 😦 it's very nice, but I have very custom pages and would have to learn custom page logic to get those to work again haha. But it was fun to play with! I may bug you in the Laravel section someday soon tho 😅
10 replies
How to remove Form from View page
@josef Thank you, I'll check into infolist
I have a relationship manager and I'm trying to show just the relationship manager on the edit or view page, but someone gave me a tabbed idea that seems to work better that I can get rid of the view page and just keep it the edit page - so I may just do that 🙂
6 replies
is there a way to use spatie roles with teams id and filament multenancy on V3 ?
I think you may want to remove the teams functionality from Spatie and utilize Filament to do the rest for you. We just need to figure out how to set the company_id to a user/role
122 replies
TLCTuto's Laravel Corner
•Created by JamesTechDude on 8/20/2023 in #💡filament
Making tabs for edit page
THAT WORKS! Thank you!
10 replies
How to remove Form from View page
@ZedoX Sorry, the view form (that lets you view the current user's information)
Typically it's an edit form, but when you make a view, it's the same edit form - just disabled
I meant to say Form, not Table - my fault
6 replies
is there a way to use spatie roles with teams id and filament multenancy on V3 ?
@DS also check that relationship and make sure it's returning what it should, use
dd($roles)
in controller function (before the return) and it should output the values it grabbed
I think I wrote the relationship incorrectly as well :/122 replies
is there a way to use spatie roles with teams id and filament multenancy on V3 ?
@tuto1902 Do you think you can assist with this? 😮 I know you know a ton about this stuff 🙂
https://filamentphp.com/docs/3.x/panels/resources/relation-managers#attaching-and-detaching-records
122 replies
is there a way to use spatie roles with teams id and filament multenancy on V3 ?
@DS So I see you are trying to put all roles into an array that belong to that specific company... I would move this to the Company model as a function:
And then you can just call that relationship instead of running the query directly, especially so it's in 1 central location in case you need to change it in the future for all spots that need to grab the roles...
Let me see about the rest though
122 replies
is there a way to use spatie roles with teams id and filament multenancy on V3 ?
With Filament, it's difficult to understand sometimes, but everything is based on the
team_id
already that you don't need to assign a team_id
in roles. I would get rid of that completely on the roles side and change your tables to have the team_id field, or have pivot tables like post_user for Posts that belong to a User
The rest is handled at the highest level of multi tenancy
As far as I know, there isn't a way yet to have multiple Roles with multiple Teams for 1 User
You can only have 1 Role with multiple Teams for 1 User. The rest is handled through the specific table themselves (like a posts
table), where a team_id is set to the specific record (or through a pivot table)
This has taken me a lot to understand too, so I get where you're coming from, but there's no way to set the team_id to the roles table as far as I've found. Instead, it's set at the resource level (Posts, Articles, etc) and in their specific tables or through pivot relationship which is still only using the team ID and the Model ID (no Role ID)
The only time you need team_id
in the role assignment table, is when 1 User has multiple Roles for different Teams122 replies
Role based access of resources
@josef said it best on another thread:
Panels are a set of resources. So you can have a panel for e.g. sales that see one set of resource, while the admin sees another. If both see the same set of resources, but have different permissions, one panel and policies should work best.
For you, it sounds like you will have the same resources for everyone but just want to limit which ones certain people see:
- First administrator can see everything
- Branch admin can manage only their own branch
- and more
In this case I would look into Policies, which is a Laravel thing that Filament will honor/use seamlessly:
https://laravel.com/docs/10.x/authorization#creating-policies
I also recommend this video that @tuto1902 made that touches bases on this policy setup, fast forward to about 57 minutes 48 seconds:
https://www.youtube.com/watch?v=a9u_ByM5YCk2 replies
Please suggest deployment servers for filamentphp3
I personally use A2Hosting, unmanaged VPS Server, Almalinux
I then SSH into it with VS Code to do any coding/editing/etc (use SSH keys! and turn off password login)
You can setup git very easily and use "git pull" and "git push" to keep up to date with your online repo (use SSH keys as well)
If you really wanted to, you can also setup a cronjob to keep it updated on it's own by doing "git pull" however often you want, but this isn't recommended for production folders
This is around $70 USD per month, though, for a fast server
For a cheap/slower server, it's as cheap as around $5 to $30 USD per month (I think)
This will give you a server to use that will be online 99% of the time. And the only way to access it is through WHM/cPanel, or SSH
You can get their managed VPS server for around $10 to $20 USD more per month, which I recommend if you're new to linux/WHM/cPanel. This will let you still have admin access (running npm, artisan, and other commands), but they will set up the server for you and manage it if you have any issues
11 replies
TLCTuto's Laravel Corner
•Created by JamesTechDude on 8/20/2023 in #💡filament
Making tabs for edit page
I made a view action using:
php artisan make:filament-page ViewLitter --resource=LitterResource --type=ViewRecord
But the problem is, this still generates the form at the top - just with a view only type / disabled fields, with no way to hide it that I can find in the documentation
I'll try messing around further10 replies
TLCTuto's Laravel Corner
•Created by JamesTechDude on 8/20/2023 in #💡filament
Making tabs for edit page
That might be the way to go 🤔 and just put the relationship manager onto its own page?
10 replies
TLCTuto's Laravel Corner
•Created by JamesTechDude on 8/15/2023 in #💡filament
How to check user roles in canAccessPanel()
Disregard, it was VS Code giving this error even though it's working... intelliphense (or whatever) for ya
55 replies
TLCTuto's Laravel Corner
•Created by JamesTechDude on 8/15/2023 in #💡filament
How to check user roles in canAccessPanel()
In my
User
model, I have:
This is giving an error saying undefined method 'hasRole'
55 replies
TLCTuto's Laravel Corner
•Created by JamesTechDude on 8/16/2023 in #💡filament
How to set company_id in role_user table
By the way,
I missed a step...
https://filamentphp.com/docs/3.x/panels/tenancy#customizing-the-ownership-relationship-name
This is mainly for things to belong to a company though, but I think this will let me get rid of updating the company_id through the create method in the model (when creating a new record)
Don't miss this step like I did haha - I'll let you know if it fixes my issues 🙂
16 replies
TLCTuto's Laravel Corner
•Created by JamesTechDude on 8/16/2023 in #💡filament
How to set company_id in role_user table
I just thought of a different way to do it as well, where I have just 1 panel for Company. Within this Panel, I would only allow resources for certain Roles
For instance,
If they have Owner and Client Role, they would see all Owner and Client resources
If they only had Client role, they would use the same Panel, but would only see Client resources - that may be the easier approach so they don't have to switch paths just to access a different Role. I just have to think more
16 replies