Laravel Pro Tips
😍 You can retrieve date from request in specific format and timezone 🤯
#laravel #laraveltips #laraveltricks #laravelforever
Laravel Updates | Tips and Tricks
🔥 If you've ever found yourself manually dealing with request inputs looking to parse it to Carbon. You might want to use the `date` method on the Request instance instead. #Laravel #PHP
Morten Poul Jensen
🔥 #Laravel Tip: If you need to render dates and times a lot in your app, then consider making a custom Carbon class. You can then tell Laravel to always use your class via the Date facade.
Carbon provides next() and previous() functions that return upcoming and previous occurrences of a particular weekday or time.
How to retrieve records between two timestamps in Laravel 🗓 Use whereBetween with a from and to date. If you need to provide fallback you can do so with the nullish coalescing operator ❔❔
Laravel Tip: Very often you need to filter the Model records based on created_date.
👉You can create scope Methods after() and before() and use them like below.
🔥 If multiple of your Models needs these methods, you can move them to Trait.
The Laravel Dev
🔥 Laravel tip: Use the CarbonImmutable class instead of Carbon to avoid changing the object without having to clone it.
🌶️ #Laravel Tip: Use Laravel Accessor/Mutator to 𝘀𝗲𝘁 Date field in UTC and 𝗴𝗲𝘁 Date field in user's current Timezone.
Working with dates with timezones is always tricky & challenging 💪
#PHP #Developers #100daysofcodechallenge
Bilal Haidar - Available 4 Laravel gigs
🌶️ #Laravel tip: Eloquent has a rich set of 𝘿𝙖𝙩𝙚 𝙬𝙝𝙚𝙧𝙚() statements. Let's check them together 🔥
Comment below if I missed any 😻
Apr 17th, 2022
Carbon PHP Practical Examples
I've been working and experimenting a lot lately with Carbon, the sublime PHP date and time utility library. I've tweeted a lot of Carbon tips and decided to collect all these tips into a permanent article.