Adding demo mode in filament application

Demo mode means the create/update/delete actions won't be applicable. I used to do this via middleware in Laravel but wanted to do similar thing but can't figure it out. Is there any easy way to add demo mode in a filament panel?
6 Replies
Tonkawuck
Tonkawuck4mo ago
You could also override the functions that perform record creation/updating/deleting on your resource to prevent database interaction. I believe the create function is called "handleRecordCreate" and there will be a similar one for edit. For delete you can make the buttons action do nothing
Raziul Islam
Raziul IslamOP4mo ago
I know that but how to determine the actions? Yes but this way I need to add the functionality on all the resources/pages. I was looking for a single code solution which will be applied to all the resources automatically. I can use observer to prevent create/update/delete but still have to apply the observer on all models (may not be a good idea) another easy solution is to just reset the database after a certain period of time
Tonkawuck
Tonkawuck4mo ago
You could create a trait to easily port this code to either all your models or resource pages depending on how you do it. You could also set your models to extend from a base model which has this functionality. There are a few ways to do this
Sjoerd24
Sjoerd244mo ago
I would just set up a seperate demo enviroment and reset the database every 10 of 15 min. This looks like a very complicated problem, also if you want to give user a "taste" of how it works. This is the same as the official filament demo website, you can find the code in Github if you need an example.
Raziul Islam
Raziul IslamOP4mo ago
Yeah
Want results from more Discord servers?
Add your server