Vigyata.AI
Is this your channel?

New Way To Load Data In Json Resource - 3 New Things Added - New in Laravel 9.46.0

2.1K views· 64 likes· 4:02· Jan 12, 2023

🛍️ Products Mentioned (6)

Here, we will be looking at 3 new things that are added to the latest version of Laravel which is v9.46.0 === OFFER === GET 30% DISCOUNT ON ALL PLANS OF CLOUDWAYS HOSTING FOR 3 MONTHS https://unified.cloudways.com/signup?id=1029148&coupon=CW30FOR3 === Important Links === Fonts, extensions I use, and Support Laratips links: https://bit.ly/m/laratips === Video Related Links === 00:00 Intro 00:19 Add whenHas to JsonResource https://github.com/laravel/framework/pull/45376 02:25 Add unless to JsonResource https://github.com/laravel/framework/pull/45419 03:12 Update decimal validation rule to allow validation of signed numbers https://github.com/laravel/framework/commit/24a48b2fa6154b2ba2e669999e73a060f9e82080 === Other Videos === What's New In Laravel 9 https://youtu.be/qAzrZUG_9Z0 New In Laravel Playlist https://www.youtube.com/playlist?list=PL2DahmvUpeuu4UVWrcxlvVkMiI0SeS2OZ Laravel Package Development Playlist https://www.youtube.com/playlist?list=PL2DahmvUpeuu8HkpbNT-cKernolVdqZq_ Password Validation In Laravel with at least one Letters, Numbers, Upper and Lowercase or Symbols: https://youtu.be/f-g3P9imPZs Multiple Apis With ForwardsCalls Trait And Code Refactoring Tip - Laravel Hidden Feature: https://youtu.be/vzgNm86ezWE Laravel Chunking - You Might Be Doing This Wrong - Problem and Solution: https://youtu.be/aQCHmB4Uh0Q Laravel Tip - Properly Get Data Between Two Dates https://youtu.be/bJkEBTg1NGA Get Data From Multiple Databases In One Project | Laravel Tip https://youtu.be/KJAXLf78QPs === Attribution === Boy waving hand Video by VideoPlasty .com from Pixabay https://pixabay.com/users/videoplasty-19751245/?utm_source=link-attribution&utm_medium=referral&utm_campaign=video&utm_content=80696 #laravel #php #laraveltip #laratips #newinlaravel

About This Video

In this video I’m covering three small but really useful changes that landed in Laravel v9.46.0. It’s been a long time since I uploaded because I was involved in some projects, but now that I’ve completed them, I’m back with a “New in Laravel” update. The first two changes are all about JSON Resources and making your API responses cleaner without writing extra if statements everywhere. First, I show the new whenHas() method on JsonResource. The key difference vs whenNotNull() is important: whenHas() only includes the key if the attribute is actually present on the model, even if the value is null. I demo it with a user where email_verified_at is null and explain why one method removes the key while the other still keeps it in the response. Second, Laravel added unless() to JsonResource, which is basically the opposite of when(). I use it to show a field only when a condition is not met (like when email_verified_at is not present). Finally, I cover a fix to the decimal validation rule: it now supports signed numbers, so +12.34 and -12.34 validate correctly with decimal:2—something that didn’t work in earlier versions.

Frequently Asked Questions

🎬 More from Laratips