Eloquent hasMany And hasOne Relationship | Laravel For Beginners | Learn Laravel

  Рет қаралды 10,305

Code With Dary

Code With Dary

Күн бұрын

This video will dive into Eloquent’s hasMany and hasOne Relationship in Laravel - Learn one of the most popular PHP frameworks for its advanced features, templating engine, fast commands and security.
📚 New Udemy Course
If you're looking to level up your Laravel skills, my new course "Udemy Migirations, Seeders, Factories, Query Builder, Eloquent & Relationships" is the perfect opportunity. Learn the essential tools and techniques for building robust and scalable web applications with Laravel: www.udemy.com/course/masterin...
📲 Let’s plan a meeting
Plan a (paid) 1-hour meeting on Calendly to do portfolio reviews, code reviews resume reviews or a coaching session for Laravel. Please read the description before booking: calendly.com/codewithdary
💌 Newsletter
Sign up for my free weekly email newsletter: www.newsletter.codewithdary.com
🔥 Resources
- PHP Hosting (10% DISCOUNT): www.hostinger.com/codewithdary
- TikTok: / codewithdary
- Instagram: / codewithdary
- Twitter: / codewithdary
- Blog: blog.codewithdary.com/
- Newsletter: newsletter.codewithdary.com/
- Patreon: www.patreon.com/user?u=30307830
- GitHub: github.com/codewithdary
Want to learn more?
- Courses: / @codewithdary
📋 Table of Content
00:00 - Introduction
00:15 - hasManyThrough() Example
00:57 - hasManyThrough() Model & Migration
02:30 - Add Data In MySQL
03:54 - hasManyThrough() Relationship
06:12 - Printing Data In The UI
09:18 - Example hasOneThrough()
09:55 - hasOneThrough() Migration & Model
10:58 - Add Data In MySQL
12:25 - hasOneThrough() Relationship
13:57 - Printing Data In The UI
#laravel #laravel8 #php #hasMany #hasOne #eloquent

Пікірлер: 28
@CODINGVENTURE
@CODINGVENTURE 2 жыл бұрын
Hey Dary, I just wanted to take the time to thank you. I started programming about four years ago while also studying computer science. During the pandemic I had to quit school and programming to get a full time job to cover my bills. I wanted to get back to my career but couldn’t find motivation after not coding for over a year. A friend refer me to learn Laravel and finding your videos has been a clearly motivational spark. I thank you so much for the content.
@codewithdary
@codewithdary 2 жыл бұрын
Appreciate it a lot man. A lot of people over here have been in your shoes. My goal is to just help you guys out man. :)
@codewithdary
@codewithdary 2 жыл бұрын
LETS CONNECT THROUGH INSTAGRAM. www.Instagram.com/codewithdary
@anthennyking2174
@anthennyking2174 3 жыл бұрын
so glad i found your yt channel really is a big help while i am going through uni :D Keep it up man i appreciate it!
@codewithdary
@codewithdary 3 жыл бұрын
I feel you so hard! And thanks man! :)
@rayadkubaisi8403
@rayadkubaisi8403 2 жыл бұрын
thanks a lot for your content , wouldnt it have been better to define the engines function in the carModel model ?
@gietece
@gietece 3 жыл бұрын
Hi Dary, at the end of video all dates are the same (from the first row of car_production_dates), A3 should be 1999, any idea how to fix it?
@codewithdary
@codewithdary 3 жыл бұрын
Use the NOW() function in a query?
@cornedejong3084
@cornedejong3084 3 жыл бұрын
@@codewithdary , Hi I've got the same question, on the dump_var($car->productionDate); it;s showing only the first entry (2007) from the DB?,. Nice course and good explanations
@tallitvak5325
@tallitvak5325 3 жыл бұрын
also having the same issue... need to somehow link car_model to the production date and not the car itself, that my guess, but im trying to come up with solution... update if i manage
@ryandanu3360
@ryandanu3360 3 жыл бұрын
i tried using hasManythrough in public function productionDate() and it works it not return only single date (27-06-2007) when showing the data in the view ( $car->productionDate->created_at ) i guess dary giving wrong example since the cars and cars_model have one to many relationship then we cant using hasOneThrough . well it works but it will only return single data or i just didnt find another solution for that problem hope this answer help u but Thank you dary u helped me alot god bless u
@rajeshbudhathoki7888
@rajeshbudhathoki7888 3 жыл бұрын
I'm also having same date issue at 15:15. The video itself shows the same date. Dary, you didn't any filter or comparison as you had done at 8:57. Thanks for the help.
@abdallhahmad9284
@abdallhahmad9284 2 жыл бұрын
Hi Dary, I have a small question , in 'created at' the dates are the same with all models of the car .... even in the video .. how we can fix this ..and thank u ♥
@cosmicfiniteinc
@cosmicfiniteinc 3 жыл бұрын
Is it the same way , Ecommerce websites use for variations in products ?
@codewithdary
@codewithdary 3 жыл бұрын
Do you mean with categories etc?
@vishalsharmaicici
@vishalsharmaicici 2 жыл бұрын
kindly tell one table relate with 10 table with unique and other table unique table
@relaxingmusicandsceneryfor5816
@relaxingmusicandsceneryfor5816 3 жыл бұрын
Hi Dary, Thank you for the tutorial. I was having a hard time having correct outputs for the productionDate. It keeps showing the first production date I entered for the car model. Here is what I did @foreach ($car->productionDates as $productionDate) @if ($model->id == $productionDate->model_id) {{ date('d-m-Y', strtotime ($productionDate->created_at)) }} @endif @endforeach and then I changed the relation from hasOneThrough to hasManyThrough do you recommend any other solution for this ?
@codewithdary
@codewithdary 3 жыл бұрын
Nah this is very good! :)
@relaxingmusicandsceneryfor5816
@relaxingmusicandsceneryfor5816 3 жыл бұрын
@@codewithdary Thank you, Hope you'll also create a tutorial on how we can add data on child tables using forms :) Thanks a lot
@danasugu1767
@danasugu1767 3 жыл бұрын
Hi, Dary. Awesome turorials ❤️. Sadly, I am getting and error when adding the engines. ErrorException foreach() argument must be of type array|object, null given. Cheched it many times but I cannot see the mistake.
@codewithdary
@codewithdary 3 жыл бұрын
just clear config cache of laravel php artisan config:cache
@danasugu1767
@danasugu1767 3 жыл бұрын
@@codewithdary Thank you, Dary!
@codewithdary
@codewithdary 3 жыл бұрын
Did it work? :)
@danasugu1767
@danasugu1767 3 жыл бұрын
@@codewithdary No, it didn't :(
@siidsharma5349
@siidsharma5349 3 жыл бұрын
may i know what tools and software you use to make/edit video
@codewithdary
@codewithdary 3 жыл бұрын
I started off with iMovie but a couple months ago I switched to Premiere Pro, I do recommend it!
Introduction To Eloquent | Laravel For Beginners | Learn Laravel
45:20
Мы никогда не были так напуганы!
00:15
Аришнев
Рет қаралды 6 МЛН
3M❤️ #thankyou #shorts
00:16
ウエスP -Mr Uekusa- Wes-P
Рет қаралды 15 МЛН
HOW DID HE WIN? 😱
00:33
Topper Guild
Рет қаралды 44 МЛН
تجربة أغرب توصيلة شحن ضد القطع تماما
00:56
صدام العزي
Рет қаралды 51 МЛН
Laravel Eloquent: Deeper Relationships with One Query
10:37
Laravel Daily
Рет қаралды 137 М.
Databases & Migrations | Laravel For Beginners | Learn Laravel
15:09
Code With Dary
Рет қаралды 50 М.
Laravel Eloquent Relationships | One To One | Part 1
10:19
AngelJay Academy
Рет қаралды 14 М.
Мы никогда не были так напуганы!
00:15
Аришнев
Рет қаралды 6 МЛН