Тёмный

Filament Livestream: Pet Clinic Admin Panel - Multi-Tenancy 

Tuto1902
Подписаться 5 тыс.
Просмотров 11 тыс.
50% 1

Let's build an admin panel for a fictional Pet clinic using Filament v3. In this live session I'll try to demonstrate my process for creating and entire project from start to finish.
phpstan.neon gist.github.co...
Code: github.com/tut...
Latest Subscriber: webthesign
Subscriber Goal: ||||||||||||||| 69% ||||||......... 3.49K/5K
Start creating Filament Admin Panels today with the Filament Bootcamp
👉jorgearturoroj...
Do you like my content? Buy me a coffee and help the channel grow ☕️ mercury.stream...
Latest tippers: MilenKo - $10.00, Sean - $5.00, Daniel GAMEL - $1.00, Mwest2020 - $5.00
Join me on Discord
/ discord
Discord Goal: ||||||||||||||| 74% ||||||||....... 223/300
Latest discord member: limewater23♯0
If you want more Filament content, check this playlist as well (great stuff)
• Filament Admin Panel

Опубликовано:

 

3 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 61   
@cometpandaskywalker
@cometpandaskywalker Год назад
videos like this is the best "advertisement" for Filament I think because even I find some of the features (of Filament) cool but I fail to find a real-life usecase for them. but if Filament can be used for an admin panel for veterinary bookings, I'm impressed 👍👏
@Tuto1902
@Tuto1902 Год назад
Thanks a lot! I'm so happy that this series is being so well received. I appreciate your comments and thank you for watching as well. It gives me the energy to keep going even when things get hard 🫶🏼
@JeffRose1
@JeffRose1 Год назад
This is great - I think Filament can be beneficial and this new multliple panels is helpful.
@midteknologi
@midteknologi Год назад
Thanks for this Livestream
@dedy962
@dedy962 10 месяцев назад
I feel i found a treasure, thank you for your tutorial about filament,
@Tuto1902
@Tuto1902 10 месяцев назад
Glad it was helpful!
@luisgustavo92
@luisgustavo92 7 месяцев назад
Omg i always have been afraid of change to filament since i always did my work "from zero", but your tutorial is encouraging me. Just one tip, in my projects, when i need to delet files when a register is deleted, i like to put the delete file code in a observer.
@Tuto1902
@Tuto1902 7 месяцев назад
That’s a great tip. Thanks!
@vugarkhalil
@vugarkhalil Год назад
wow, Respect
@raheeldharolia2673
@raheeldharolia2673 6 месяцев назад
Thank you for the streams, really liking em. One quick question, what if the appointment records also have files/images etc, how does we delete those files/images on cascade deletion. Thank you.
@Tuto1902
@Tuto1902 6 месяцев назад
Either with a before/after delete hook or directly setting cascadeOnDelete directly in the migration of the table that holds the image, thou I believe a combination of both is needed since we have to cleanup leftover files
@DanielDrummond2k6
@DanielDrummond2k6 Год назад
It's very simple to have a count of the number of items in a resource and it doesn't need to be a widget. In the resource file just call this function. protected static function getNavigationBadge(): ?string { return static::getModel()::count(); }
@joaofelipern
@joaofelipern Год назад
great.. thank you
@Tuto1902
@Tuto1902 Год назад
You are more than welcome!
@engbz
@engbz 3 месяца назад
Thanks for the series. How should we do this if we want a user to create only one team and be limited to that 🤔
@Tuto1902
@Tuto1902 3 месяца назад
I would go with a TeamPolicy with a create method that checks the count of teams for a user. If the user has zero teams, allow the creation (return true) if the user has one team already, return false. laravel.com/docs/11.x/authorization#policy-methods
@engbz
@engbz 3 месяца назад
@@Tuto1902 public function create(User $user): bool { if (auth()->user()->teams()->count() >= 1) { return false; } return true; } This way I got what I wanted. Thanks again
@Tuto1902
@Tuto1902 3 месяца назад
@@engbz just a note, you don’t need to reach for auth()->user() since the $user parameter gives you the currently logged in user
@engbz
@engbz 3 месяца назад
Great warning. Thank you. I am correcting ❤
@Tuto1902
@Tuto1902 Год назад
All of the changes made in this live stream are now merged into the github repo: github.com/tuto1902/filament-pet-clinic You can check out the pull request for a complete list of all the changes we made during the live stream: github.com/tuto1902/filament-pet-clinic/pull/1 I really had a blast and I can't wait to see you in the next live stream ❤ If you have further questions, you can join me on Discord discord.gg/z9EcwGzM
@JamesAutoDude
@JamesAutoDude Год назад
When using the $table->foreignIdFor trick, make sure to add ->constrained() to the end, or the relationship wont be made in the database... Would also have to add your actions like: ->onUpdate('cascade')->onDelete('cascade'); So the full code should be: $table->foreignIdFor(User::Class)->constrained()->onUpdate('cascade')->onDelete('cascade'); This trick also requires the Model to be setup for the class, obviously lol
@Tuto1902
@Tuto1902 Год назад
Thank you for sharing. This is valuable knowledge 🔥
@easyjapaneseforall
@easyjapaneseforall Год назад
awesome Live: 47:07
@raheeldharolia2673
@raheeldharolia2673 6 месяцев назад
I am using Larashift Blueprint to generate migrations and Models, you define your Models, fields and relationships in one go in a .yaml file and do php artisan blueprint:build so I don't have to write the migrations and relationships. It's a breeze to work with atleast in the beginning of the project. Later on we may edit the migrations manually. Must try it's cool
@Tuto1902
@Tuto1902 6 месяцев назад
It sounds cool. Thanks for sharing!
@Bonfimcosta1
@Bonfimcosta1 Год назад
Your video is very good. Is there a possibility to include selecting the clinic on the login screen?
@Tuto1902
@Tuto1902 Год назад
Sounds like an interesting idea. You can for sure edit the login. I’ll look into it. Would you mind posting this question in my discord server so I can follow up? (Link in the video description)
11 месяцев назад
Hello Arturo, thanks for the videos, are great !!!!! At minute 41:26, you said there was another video of someone who had implemented the Spatie package in Filament, could you give me the link please?
@Tuto1902
@Tuto1902 11 месяцев назад
It's not a video but a plugin for managing roles and permissions using the spatie package in filament filamentphp.com/plugins/tharinda-rodrigo-spatie-roles-permissions
@samnaghavi9775
@samnaghavi9775 Год назад
I also have another question which is how to send the current user id that is feeling the form to the data base?
@Tuto1902
@Tuto1902 Год назад
It would help to have a bit more context, but generally speaking, the user filling the form is always the logged in user, which you can get from anywhere in your code using auth()->user(). This returns the currently logged in user. You can the the user id like this: auth()->user()->id
@samnaghavi9775
@samnaghavi9775 Год назад
@@Tuto1902 well the context is in my blog table I have user_Id but when I created the my blog Resource filament made user_id as a select field for some reason! which the user can see all users and select it!!! and I want to remove that select field and instead send the current user_id. but I don't know how to do it in filament . where should I put this code? auth()->user()->id.
@Tuto1902
@Tuto1902 Год назад
I understand. Thank you for elaborating. Open your CreateBlog.php page (app/Filament/Resources/BlogResource/Pages) and add the following function protected function mutateFormDataBeforeCreate(array $data): array { $data['user_id'] = auth()->user()->id; return $data; } You can read more about customizing the creation process here: filamentphp.com/docs/3.x/panels/resources/creating-records#customizing-data-before-saving
@samnaghavi9775
@samnaghavi9775 Год назад
First of all, thank you for your awesome channel. In the last stream, I was trying to do the same thing, but I had a problem with the select options. Every time I tried to select them, the options loaded really slow. I noticed that every time I'm hitting the select menu, it sends a new query and won't store data at all. So, I came up with this solution: $typeOptions = Patient::groupBy('type')->pluck('type'); return $form ->schema([ Select::make('type') ->native(false) ->options($typeOptions) ->required(), // more code... ]);
@Tuto1902
@Tuto1902 Год назад
The only issue I see here is that you only get types based on the existing patients. What if there are no patients? You'd get an empty select input. Have you tried the ->preload() method on the Select input? Finally, I can't assume anything about your local dev environment. But if by any chance you are working on Windows using WSL2, make sure the files of your project are inside WSL and not in a folder on the Windows file system. For example: I used to have a symlink in my WSL home folder, pointing to /mnt/c/Users/arturo/Code. And I would do php artisan serve (or sometimes sail up) on those projects from WSL. This would cause my apps to run extremely slow. Moving my project files to the WSL (Ubuntu) file system solved my issue.
@samnaghavi9775
@samnaghavi9775 Год назад
@@Tuto1902 I was guessing that part of the problem was my windows being slow but from logical standpoint it is not logical to send a request to database everytime someone presses on select. and yes I tried preload as well but it was still very slow() unfortunately
@Tuto1902
@Tuto1902 Год назад
I get your point. If performance is imperative, you don't want to constantly hit the database for a select input, and you know your options won't change very often, you can try adding query caching. The ->options() method accepts a callback function and you can type-hint the model class you want the options from. Then, you can use Cache::remember() and store your options in cache for a while.
@ifeanyinnaemego
@ifeanyinnaemego Год назад
I have not finish the video. But i am wondering if the tenancy can be used to add a subdomoman for each registered member
@Tuto1902
@Tuto1902 Год назад
I don’t think that’s available
@christostsangaris4785
@christostsangaris4785 Год назад
Can filament offer multitenancy for multiple dbs and subdomains in contrary to the same db and same domain? Thank you!
@Tuto1902
@Tuto1902 Год назад
They offer domain settings but it’s for panel configuration. Not specifically for tenancy. And don’t think database tenancy is available.
@Tuto1902
@Tuto1902 Год назад
filamentphp.com/docs/3.x/panels/configuration#setting-a-domain
@christostsangaris4785
@christostsangaris4785 Год назад
Thank you so much for the swift response @Tuto1902! Keep up with the quality video and knowledge you post!
@JamesAutoDude
@JamesAutoDude Год назад
What if someone has a Role of "user", but also needs the Role of "admin". I suppose it would require another pivot table to do role_id with user_id, but then I'm wondering how they would log in too. I guess depending on what URL path they login to? Hmmm... What I also did in the role_user pivot table, was adding a clinic_id field where I can figure out what clinic they are a part of for that specific role which may help with having multiple companies with multiple roles... we will see lol
@Tuto1902
@Tuto1902 Год назад
Yes, you would need a role_user pivot table. If I were to do it, I'd just use the canAccessPanel() function on the User model (required when the user model implements the FilamentUser contract). If the user doesn't have the role required to access the current panel, you would get a 403 error page
@JamesAutoDude
@JamesAutoDude Год назад
@@Tuto1902 Thank you. I can't seem to figure out how to use the Roles to tell us what panel to allow access to, hopefully in a future video?
@SebastianPerezG
@SebastianPerezG Год назад
Question , i have this structure in storage folder , storage/app/public/uploads/banners , but i can find any doc on how to setup this on filament , i mean , i make another disk pointing to this directory called banners , also i made another storage link but nothing is working or showing in the table. i'm using the disk() method in the table and the ImageColumn property but also no luck. the image is stored in the database without any url and just the filename and extension.
@Tuto1902
@Tuto1902 Год назад
It would be hard to answer without looking at some code. Would you mind posting this question in my discord server (filament technical help channel) and share the code of your create page and resources table? discord.gg/mf5qGJBmQH
@yuliarahma1300
@yuliarahma1300 Год назад
can we move or hide or overide the default aciton button on resources when create/edit ? im using wizard on my form but the default action button still appear on the bottom, thanks.
@Tuto1902
@Tuto1902 Год назад
Yes, you can override the getFormActions() method on your Edit and Create page and just return an empty array protected function getFormActions(): array { return [ //.. ]; }
@yuliarahma1300
@yuliarahma1300 Год назад
@@Tuto1902 yeay, it works, thanks a lot. 🙏🏻
@Tuto1902
@Tuto1902 Год назад
Happy to help 😉
@sabinmagar4152
@sabinmagar4152 Год назад
in my case user created error and may not connected with clinic_user table as pivot id how to fixed..?
@Tuto1902
@Tuto1902 11 месяцев назад
If you are only on stream #2, don't stress too much about multi-tenancy. It will be removed from admin panel and then re-added to only the doctors panel in a future stream. But all you need to be careful is to have the Clinic as the panel tenant and that the User model has the appropriate relationships
@sabinmagar4152
@sabinmagar4152 11 месяцев назад
@@Tuto1902 its okay but i have another question. How to make Settings page in filament where it has company logo , footer description, Social links etc fields?
@Tuto1902
@Tuto1902 11 месяцев назад
@@sabinmagar4152 Unfortunately that is quite a broad question. Hard to answer in a RU-vid comment. You can probably start by looking into filament custom pages and using the form builder in a custom page.
@JamesAutoDude
@JamesAutoDude Год назад
Are you able to help me with this error? Target class [App\Providers\Filament\Clinic] does not exist.
@JamesAutoDude
@JamesAutoDude Год назад
Nevermind, I forgot to import the class in the PanelProvider file lol
@Tuto1902
@Tuto1902 Год назад
I was about to say that 😉
@ashlirenier6390
@ashlirenier6390 Год назад
'PromoSM' 😭
@Tuto1902
@Tuto1902 Год назад
👆🏼 Can someone explain what is PromoSM? Is it spam?
Далее
Filament Livestream: Pet Clinic Admin Panel - Policies
2:48:15
Living life on the edge 😳 #wrc
00:17
Просмотров 2,8 млн
Step-by-Step Guide to Filament Multi-Tenancy
17:39
Просмотров 9 тыс.
The Value of Source Code
17:46
Просмотров 51 тыс.
The Laravel Livestream 🚀 Text To Ads
2:03:07
Filament Livestream: Pet Clinic Admin Panel - New Project
3:15:02
The Tools I Use to Build Products in Laravel
19:00
Просмотров 31 тыс.
Multi-tenancy in Laravel
1:24:05
Просмотров 6 тыс.