MilenKo
MilenKo
Explore posts from servers
TLCTuto's Laravel Corner
Created by MilenKo on 10/2/2024 in #💡filament
Spatie Settings with Filament CheckboxList
Nevermind, Tuto, I've figured it out, it was just that in the DB I did not define the initial column payload as [] but '' and not sure why but since I switched to that and set my variable as an array type, I got it working perfectly. So my current settinfs page has the following definitions (in case you ever fall into this, despite I doubt it): GeneralSettingsPage.php
// All CheckboxList options: https://filamentphp.com/docs/3.x/forms/fields/checkbox-list
CheckboxList::make('site_checkboxlist') // checkbox list with supplied options
->options([
'1' => '== A ==',
'2' => '== B ==',
'3' => '== C =='
]),
// All CheckboxList options: https://filamentphp.com/docs/3.x/forms/fields/checkbox-list
CheckboxList::make('site_checkboxlist') // checkbox list with supplied options
->options([
'1' => '== A ==',
'2' => '== B ==',
'3' => '== C =='
]),
GeneralSettings.php
// Define the settings page inputs to use in the Settings Page
public array $site_checkboxlist; // Note: Changed this back to an array
...
// Define the settings page inputs to use in the Settings Page
public array $site_checkboxlist; // Note: Changed this back to an array
...
And my settings table migration:
...
$this->migrator->add('general.site_checkboxlist', []); // checkbox list input
...
...
$this->migrator->add('general.site_checkboxlist', []); // checkbox list input
...
Just sharing the solution here, but the working code can be seen in the repo and I am moving forward with other inputs to see what hides there as well 😉 At least I can handle arrays now in Filament to properly store the values... 😉
8 replies
TLCTuto's Laravel Corner
Created by MilenKo on 10/2/2024 in #💡filament
Spatie Settings with Filament CheckboxList
No description
8 replies
TLCTuto's Laravel Corner
Created by MilenKo on 10/2/2024 in #💡filament
Spatie Settings with Filament CheckboxList
Thank you in advance. Trying to do and share some good with the Open Source community but this wone seems to be a tough nut to crack. Btw, the Filament + Jetstream - I did it already and the code is in the repo, so now we have 2FA in the user profiles while using Filament 🙂 And there seem to be many useful plugins for a starter pack, but I just can't get on hold of the array<>string type var storing... It definitely has to do something with the casts, but I am not really sure which cast to use and how to pass the proper parameters as most (if not all) casts available in LaravelSettings plugin I've tried but could not make it work as it should..
8 replies
TLCTuto's Laravel Corner
Created by MilenKo on 10/2/2024 in #💡filament
Spatie Settings with Filament CheckboxList
Hey @tuto1902 Maybe you've had such a need in all the project and have resolved it somehow? I've posted the link to my repo for the full source if that helps... All I need is to store a CheckboxList data of checked boxes to the Settings $site_checkboxlist variable and DB. Defining it as an array type returns an error that I am trying to store sting to an array type variable, defining it as a string returns reverse, so I am buffled for almost a week now and can't figure out what on Earth is happening... No AI so far could help as well 😦
8 replies
TLCTuto's Laravel Corner
Created by MilenKo on 9/13/2024 in #💡filament
Action column Label
I did ask in Filament discord as well as i posted on Filament github issues but I assume it was taken as is that the column of actions does not have an alignment option and I sort of moved on as not worth banging head agains a wall for such a small thing. Maybe it is just me who is stubborn and wanted to figure things out but seems like nobody else ever needed such... It still makes sense to me to have such option as for LTR or RTL we need to be able to move any column text, but seems like only Actions have been excluded from this. Matybe it is a bug afterall or maybe it was a "by design" thing with some other concerns I am not seeing in the bigger picture...
4 replies
TLCTuto's Laravel Corner
Created by MilenKo on 9/1/2024 in #💡filament
Filament Labels not showing in bold
Thanks to my stubborness once I've found that the issue was related to database pivot table, I returned to my originaly started project as it has the latest Laravel 11 + Livewire and I made it work,. The only issue left is the styling of TailWind which awkwardly works on some components and not on others, but I will check this out later as well throughout the course...
9 replies
TLCTuto's Laravel Corner
Created by MilenKo on 9/1/2024 in #💡filament
Filament Labels not showing in bold
Interestingly, seems like the pivot table 'course_user' is not storing data as it should and after a fresh migration and seeding the CourseSeeder, the pivot table still got empty and since the user had no course assigned to it in the pivot, it did not work... Adding manually the course with user IDs resolved the issue so I will continue as I am pretty sure we won't use seeders later on so the code changes should overcome this issuie... Finally I can contunue to finish 13 and move on to next one
9 replies
TLCTuto's Laravel Corner
Created by MilenKo on 9/1/2024 in #💡filament
Filament Labels not showing in bold
Troubleshooting further your code with some extra logging abilities, I got this in my WatchEpisode.php mount method: Log::info('Mounting WatchEpisode', ['course' => $course, 'episode' => $episode]); try { $this->authorize('view', $course); } catch (\Exception $e) { Log::error('Authorization failed', ['error' => $e->getMessage()]); abort(403, 'Unauthorized'); } and it returned the results for $course and $episode as well as:
[2024-09-04 17:45:51] local.ERROR: Authorization failed {"error":"This action is unauthorized."}
[2024-09-04 17:45:51] local.ERROR: Authorization failed {"error":"This action is unauthorized."}
Now the question is, why would it not work using: $this->authorize('view', $course); when a wile back it was working perfectly fine and I am using your own code without even trying to upgrade the Laravel version (current one is 10.43.0)...
9 replies
TLCTuto's Laravel Corner
Created by MilenKo on 9/1/2024 in #💡filament
Filament Labels not showing in bold
To continue further my issue, I downloaded fully your branch 12 and set it up to be able to login with proper credentials etc. I am still experiencing the same issues, but now I have another issue (same with your repo - 403 when I try to navigate to: https://tuto-lms.test/courses/1/episodes/1 There are no logs to help me figure this out and it is strange as even with your official repo source it still shows me the same issues: 1. Tailwind styles are partially showing (Sections only) 2. route('courses.episodes.show) returns 403 having: Route::get('/courses/{course}/episodes/{episode?}', WatchEpisode::class) ->middleware(['auth']) ->name('courses.episodes.show');
9 replies
TLCTuto's Laravel Corner
Created by MilenKo on 9/1/2024 in #💡filament
Filament Labels not showing in bold
No description
9 replies
TLCTuto's Laravel Corner
Created by MilenKo on 9/1/2024 in #💡filament
Filament Labels not showing in bold
Also, everything gets applied properly in terms of weight('font-bold') when a video gets played, so I am even further bufled why it won't work only on Labels inside of an infolist but work correctly on Section titles and text content inside the sections... Go figure...
9 replies
TLCTuto's Laravel Corner
Created by MilenKo on 9/1/2024 in #💡filament
Filament Labels not showing in bold
For what it worth, I am seeing the proper fond size and weight in Section Tilles (Filament Bootcamp and About This Course) but not inside the sections...
9 replies
TLCTuto's Laravel Corner
Created by MilenKo on 7/23/2024 in #🚀laravel
Laravel Cashier (Stripe) payments with form validation, database record and a success message
@tuto1902 Actually, I seem to still have a small question now that it is all moving. Since I am offering a trial period for my subscription, what Webhooks should I specifically listen to so that: 1. When the user has passed his payment details (I won't allow a trial without providing a payment method) what will be the hook for starting the trial, ending the trial and switching to the actual paid premium. There are so many Webhooks and I am confused now which webhook to listen to when: 1. User has provided the payment data and is now on Trial 2. Trial notification of the expiry 3. User cancelled the trial 4. Trial ended 5. User is now an official premium. Knowing those would allow to code any action and switch successfully a user to the trial, from trial to the premium of to removed if the subscription got cancelled...
7 replies
TLCTuto's Laravel Corner
Created by MilenKo on 7/23/2024 in #🚀laravel
Laravel Cashier (Stripe) payments with form validation, database record and a success message
Since we've spoke about Webhooks, time to use those (again, tuto's "fault" for showing us the Stripe powerhouse weapons 😉 ) So I've set a new POST route to allow Stripe to trigger the events on that route. Don't forget to point to Stripe dashboard and provide either the FQDN URL or use the steps to communicate with Stripe CLI on your local server. After making sure we get 200 response on our local event listener, I load the entire payload of Stripe from the request, extract the user stripe_id to pull up all his resources and from there with some extra payload code, I find the specific resource that the user paid to have it posted (as per the needs of my project, but yours might differ). Once we've found the resource that has been paid for successfully, all that is left is to just watch it's status to Active/published etc. For sure, if we have an expiring subscriptkon, we need to configure another webhooks listener for delete event so that once it happens, the status of the resource gets back to it's previous one (prior to the payment success). Stripe is full of webhooks and some I will explore further (e.g. the one that notifies the user via email 7 days prior to the subscription expiration). This way user gets a nice email advising to pay to avoid service/premium disruption... There you go my friends, maybe not the simplest/best/optimal way but it seems to work so far well on my side. P.S. It took me quite a while to figure out the 403 error so make.sute that your webhook route is not behind a.middleware (auth or others). Also you would want to exclude Stripe from the default CSRF verification of Laravel by adding it to exceptions in CSRFValidation config in /app/Middleware. That is it, that is all, thanks again Tuto for.yhe cool video right on time for my project needs 😉
7 replies
TLCTuto's Laravel Corner
Created by MilenKo on 7/23/2024 in #🚀laravel
Laravel Cashier (Stripe) payments with form validation, database record and a success message
Hey Tuto, no worries at all man, you can't realize (maybe not to it's full extent) how much you are helping us with your amazing videos. I think I got the proper workflow for my needs so here it is what I came up with as a working workflow, in case someone else needs the use: 1. Create a form with all the required by design inputs. I am using jquery-validator for the frontend validation of the form. 2. Using a small JavaScript I make sure to trigger the form validation before passing the form data to the controller. (for sure the form points to a route accepting POST request) 3. Since the browser validation can easily get me tampered using dev console or any other tools, we need to secure our stored data with a server side validation on the data from $request (if data passes the validation, we move on, if not, return to the required URL/route with a message of your choice. 4. Since our data is validated, we store the resource with a status (inactive or draft as it is in my case) 5. We pass the Stripe price_id to checkout (see tuto's video if still unclear) and after payment we get redirected to the required URL for success or cancel. In my case I returned to my success_urk with a confirmation message passed to the route as a parameter, e.g. ?result=success
7 replies
TLCTuto's Laravel Corner
Created by MilenKo on 7/23/2024 in #🚀laravel
Laravel Cashier (Stripe) payments with form validation, database record and a success message
So for step 1 - zero issues - form setup in a view is easy-peasy. For form validation after POST to a route - same thing. For the payment process - this is where the issue appear as the Stripe redirect for payment has it's own return URLs ('success_url' or 'cancel_url') so any other code executed in the same controller after would not get called/executed). My question is - what would be your suggested and most secure workflow to achieve a safe DB record after a successful payment only making sure that the data cannot be tampered by the end user un/intentionally? My thoughts are to store the ressource with a status as Draft BEFORE forwarding to Stripe payment. Once the Stripe processing succeeds and the user is redirected to the success_url, I can execute an Ajax POST request to a custom route and trigger a controller method to update the status of the ressource to Active. It would all have been simple, but the 'success_url' and 'cancel_url' are GET type routes, so this means that I can navigate to the routes directly and have a record in the database manipulated. Not sure if I worry too much about security and missing some valuable point that prevents such an action or it is a bad workflow so that is why I am checking up to see what would you have done (or any other) in a similar scenario to guarantee the record is only switched to PREMIUM after a true payment success and not with some tampered data, route response and POSTMAN 😉 Thanks in advance for sharing the idea/approach they see as safe and secure enough...
7 replies
TLCTuto's Laravel Corner
Created by MilenKo on 2/21/2024 in #🚀laravel
Laravel notifications approach for live messasges
Stepping back from the coding board and coming back to it to attack at a different angle, I think I found the easiest and simplest solution already. 1, I will pull up the unread messages count inside the default layout (app.blade.php) and show the markup with the number. 2. If the unread messages count is zero, I will keep the value but hide the markup with the notifications counter. 3. Inside my event I will no longer broadcast the number of messages but just a plain notification with something like: NewMessageReceived. 4. On the receiver side (again inside the default layout wich would extend any other view) will add the channel of Pusher to listen to. So once a new event of type: NewMessageReceived is passed from Pusher servers to the app, I will read the current value of the notifications from the markup (that is why I will hide it and not remove from the markup) and from there either increase it accordingly. With this approach I will have to add another event when the user opens his messages from the sender so that when this event is received in the default layout, the counter gets zeroed. If anyone has a better idea, feel free to share, but I do not see any flaws (besides the end user tinkering the counter which could lead to an incorrect notifications count, however if he does, he won't expect a correct notifications count anyway. And yes, to secure the comms, I am using the Chatify message structure for notifications channel of type: message-channel.id which is behind the middleware.
5 replies
TLCTuto's Laravel Corner
Created by MilenKo on 2/21/2024 in #🚀laravel
Laravel notifications approach for live messasges
If you've done it in the past, what was your approach or if not, what would you suggest I should use as to: 1. Optimize the server load 2. Elegance and reading of code avoiding duplicate content 3. Minimize Pusher events (as we all know those are free but for a limit as of today for 5000 events per day). And yes, I know I can use websocket inside my app but for now we aim at having v1 sooner than having the best app much later.
5 replies
TLCTuto's Laravel Corner
Created by MilenKo on 2/21/2024 in #🚀laravel
Laravel notifications approach for live messasges
Currently, the way i see this happening is: 1. Inside the default layout I will pull the array of x-messages or filter only the unread X messages and insert the total count inside the markup where the counter should be (of course a simple if statement will hide the counter if no new messages are to notify of). 2. Inside the NewMessageEvent (let's call like that my event file) I will pull from DB again the number of unread messages whcih will then be pushed to Pusher.com as data + the unread messages count variable. 3. From any of the templates that extend the default layout, since we have the pusher event code in the default, i will be able to listen for an event named NewMessasgeEvent (or whatever it got defined inside of my event file to broadcastAs()) and if i see such, I will pull the data.unread_messages_count and update the markup using JavaScript (or later i can switch to LiveWire once it is proven to be working as a proof of concept). So with this approach I have thought to prevent the server overloading when there are 10-20K of users, to not pull the entire message data to show as markup in the dropdown but to use JSON and fire an even to pull the data only if the user clicks on the notifications menu. As such I am in a need to have 2 DB queries - one in the default layout every time the page gets reloaded and 2 - when a new event is fired so to pass to the event at the web socket the total unread messages count to update. Why I thought this would be the good approach was that when I register/authorize, I will pull the real data from DB and show the count properly (or hide the markup simply). If a new message is fired, I will update the counter again with the proper count. Were I see a flow is if I click on a message and read it as if i read it, I should update the counter to either lower the count or hide it if a single event was. And for that I am thinking i should fire an event or listen for an existing from Chatify to update the counter again.
5 replies
TLCTuto's Laravel Corner
Created by Yassine on 12/7/2023 in #💡filament
Multi-tenancy
Hello @Yassine Can you please be a bit more specific what is not that clear for you with multi-tenancy?
6 replies