Vigyata.AI
Is this your channel?

Convert Has Many Relationship To Has One - 2 New Things Added - New in Laravel 10.4.0

2.9K views· 81 likes· 4:10· Mar 20, 2023

🛍️ Products Mentioned (6)

Here, we will be looking at 2 new things that are added to the latest version of Laravel which is v10.4.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 === https://github.com/laravel/framework/compare/v10.3.0...v10.4.1 00:00 Intro 00:40 Add @style Blade directive https://github.com/laravel/framework/pull/45887 02:51 Adds database query count test expectation helper https://github.com/laravel/framework/pull/45932 03:15 Cloudways Sponsorship === Other Videos === 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

Hey guys, welcome to Laratips. In this video I’m going through what’s new in Laravel v10.4.0, and I focus on two changes that make day-to-day Laravel code a bit cleaner—especially if you care about keeping things simple and not repeating yourself. I also show a quick real example from one of my projects where a user has many pages, and I only want the latest page. First, Laravel 10.4 adds a way to convert a HasMany relationship into a HasOne on the fly. Since HasMany and HasOne share the same table structure, you can take an existing hasMany relation and call `one()` on it, then chain things like `latestOfMany()` without rewriting the whole relationship twice. The result is cleaner code: no duplicate relationship definitions, and it’s super readable. Second, there’s a new testing assertion for HTTP 415: `assertUnsupportedMediaType()`. It’s a small addition, but it makes tests more expressive when you’re validating content types. I also mention Cloudways as the sponsor—managed hosting that helps you go live fast and scale when you need it.

Frequently Asked Questions

🎬 More from Laratips