Laravel Eloquent: Deeper Relationships with One Query

Поделиться
HTML-код
  • Опубликовано: 1 фев 2025

Комментарии • 181

  • @chengkangzai
    @chengkangzai 3 года назад +70

    This will soon be the one of the most viewed video in this channel 😂 good work

  • @pankajbokdia
    @pankajbokdia 2 года назад +12

    I cannot thank you enough! Your channel is AMAZING! Thank you for doing what you do!

  • @tiagotheoliveira
    @tiagotheoliveira 3 года назад +33

    This packages should be in the framework. They're really good.

    • @LaravelDaily
      @LaravelDaily  3 года назад +3

      Anyone can add anything to the framework, it's open-source, so you can try.

    • @KgfLikia
      @KgfLikia 3 года назад

      Ι was about to say the same.

  • @philipcook6191
    @philipcook6191 2 года назад +1

    Soon to by membership this month. Your way of explaining wastes no time and you to the point and so knowledgeable, been watching for year but I need to get into your full courses. Thanks for this, a super help. From cape town, south africa.

  • @0x0456
    @0x0456 2 года назад +2

    This is EXACTLY what I needed to see. Thank you so much!

  • @auroraapps1853
    @auroraapps1853 2 года назад

    Superb Laravel specialized developer of all the time. I like you Sir

  • @worthsalive
    @worthsalive 2 года назад +1

    You just earned a new subscriber. Kudos to you. You just showed me exactly what I needed to see

  • @СтаниславЧетвериков-з2м

    Большое спасибо) смотрю каждый день. Всегда очень полезно

    • @NikitaHoncharovv
      @NikitaHoncharovv 3 года назад

      Реал, не сложно говорит. Прекрасно понятно

    • @ARMONEY666
      @ARMONEY666 3 года назад

      Иногда такие вещи показывает что удивляешся

  • @bilaljan7659
    @bilaljan7659 2 года назад

    that is what i was searchingfor an hour, thanks alot sir !!!

  • @levieraf
    @levieraf 3 года назад +3

    Dude! you are awesome, so so accurate!
    You are a good teacher! I love your channel!
    Great work!

  • @abdalkhalekchamkha3622
    @abdalkhalekchamkha3622 Год назад

    you are the best ,thanks you for improving my laravel knowledge, i was do stupid things before i see this video 😅

  • @DennisBraga
    @DennisBraga 3 года назад

    Life saving tip. Life saving package. Congrats to both.

  • @glowiever
    @glowiever 2 года назад

    finally the addon is mature enough to use! nice tutorial.

  • @ValeriyaPolovinkina
    @ValeriyaPolovinkina 3 года назад +1

    Thank you for this video. In real life we need in one query some fields from first level, some from second level, third, etc. But it is another story =)

  • @shahosanandaji9894
    @shahosanandaji9894 Год назад

    You are the best, Povilas!

  • @HadiHasanpur
    @HadiHasanpur Год назад

    Many thanks You are best in yours job ... I cannot thank you enough! Thank you teacher for your trainings!

  • @AlexTheGreatish
    @AlexTheGreatish 3 года назад +4

    This is great thank you.. Could you do a video explaining the different type of relationships and how the database structures should be set up in terms of where foreign keys are, etc?

    • @LaravelDaily
      @LaravelDaily  3 года назад +1

      I have an article: blog.quickadminpanel.com/eloquent-relationships-the-ultimate-guide/
      Also, it's best to read the docs: laravel.com/docs/8.x/eloquent-relationships

  • @MahmodurRahmanShihab
    @MahmodurRahmanShihab 3 года назад +1

    Thanks for your laravel daily tips.

  • @hamzaradouan4074
    @hamzaradouan4074 3 года назад

    I literally needed to know this, thank you so much 💓 keep up the great work 💪

  • @KasimSheyi
    @KasimSheyi 3 года назад

    Your videos are always wonderful.

  • @AldhiAlbadri
    @AldhiAlbadri 3 года назад +1

    Problem solving, thanks sir!

  • @azeroth5672
    @azeroth5672 3 года назад

    This is what I need!!! Thankyou so muchh for this

  • @vigneswarans13
    @vigneswarans13 11 месяцев назад

    Excellent explanation 🎉

  • @msdeav
    @msdeav 3 года назад +2

    Really helpful video. Thank you

  • @demeja16
    @demeja16 3 года назад +9

    Очень крутое видео, спасибо за улучшение наших знаний в Laravel:)

    • @maxgoose4671
      @maxgoose4671 3 года назад +2

      ну я хз понял ли он)

  • @KirillHybrid-f4f
    @KirillHybrid-f4f 3 года назад

    Something done with few lines I have to do with complex sql queries with joins, to do the same on old projects running over laravel 5.2 in my main work. Thank for this video.

  • @shaadishtiaque2084
    @shaadishtiaque2084 3 года назад

    Your tutorials help a lot... Thanks

  • @jeanfrancois3605
    @jeanfrancois3605 3 года назад

    OMG, this is amazing thank you so much!

  • @AbdulMajeedShehzad
    @AbdulMajeedShehzad 3 года назад +7

    Thank you for the great video, I've a question for this scenario. is it a good practice to use keys in deep relations ? for example in employees table we add country_id to avoid complex queries when working on reporting. I've been looking for this answer for quite a long time

    • @kauandouglas
      @kauandouglas 3 года назад

      Up

    • @javieru5871
      @javieru5871 2 года назад

      Feel you bro, done the same: usign foreign keys to those deep deep relationships

  • @aineelzihnee9634
    @aineelzihnee9634 3 года назад

    First time seeing video on youtube without dislike button being tick.

  • @md.robelahammed4763
    @md.robelahammed4763 2 года назад

    Amazing content. It helps me a lot. Thanks

  • @ChangeYourLifeForever
    @ChangeYourLifeForever 3 года назад +1

    by this video you can understand the principle of has_many and belongs_to in other languages and frameworks also

  • @TrizenGen
    @TrizenGen 3 года назад

    you always provide good content

  • @arashpirhadi1326
    @arashpirhadi1326 3 года назад +3

    great video thanks. :)
    but i think in some situation like this performance will drop after 2 joins and more.
    I mostly using DB facade for retrieving data from database.

    • @LaravelDaily
      @LaravelDaily  3 года назад +2

      Yes, for complex queries raw queries are still the best.

  • @JamesShisiah
    @JamesShisiah 3 года назад

    This is really great. Love it

  • @alexandergontsov6219
    @alexandergontsov6219 Год назад

    Really good job. Thanks 🙏

  • @codepilot2766
    @codepilot2766 3 года назад

    This is awesome bro......It will help me a lot :)

  • @Matheus708
    @Matheus708 2 года назад

    Wow! that`s really really awesome!

  • @cethartest469
    @cethartest469 3 года назад

    awesome, thanks you, please more and more advanced eloquent

    • @LaravelDaily
      @LaravelDaily  3 года назад

      I have a full course about advanced eloquent: laraveldaily.teachable.com/p/laravel-eloquent-expert-level

  • @MUJAHIDKHAN
    @MUJAHIDKHAN 3 года назад

    Thank sir , one of the best video

  • @Dinookys
    @Dinookys Год назад

    🎉 save the day, thanks a lot

  • @vbadheli
    @vbadheli 3 года назад +2

    Thank you.. this help me a lot..

  • @biplobshaha2829
    @biplobshaha2829 Год назад

    Thank you so much. It's help me a lot.💝💝

  • @hostname47
    @hostname47 3 года назад

    very very very helpful package thanks !

  • @sir_brian_d
    @sir_brian_d 3 года назад

    6:03 the query count went down but the time & memory usage went up, less performant 🤔maybe it is not using an index

  • @nbqenglishvietsubstyle117
    @nbqenglishvietsubstyle117 3 года назад

    You are a god to me, thank you so so much

  • @aryarizkysandi8351
    @aryarizkysandi8351 2 года назад

    thank you very much for tutorial sir!!

  • @amrqawasmeh
    @amrqawasmeh 2 года назад

    Thx for the great content

  • @yogeshwarbarai9686
    @yogeshwarbarai9686 Год назад

    what ide setup you use ? It looks so good and to the point

  • @tarekalhalabi8776
    @tarekalhalabi8776 3 года назад

    Great video💙

  • @g3n1kindra
    @g3n1kindra 3 года назад

    this help me a lot, thanks

  • @DANJ93Mort
    @DANJ93Mort 3 месяца назад

    Awesome! Thanks

  • @poplach
    @poplach 3 года назад

    Very informative video, thanks.

  • @tamimikbal28
    @tamimikbal28 3 года назад +1

    You are awesome 😍

  • @johnerrolprincipe8992
    @johnerrolprincipe8992 Год назад

    Hi, I watched your video about function's return type, is there any documentation about the full list of return types? Thank you!

    • @LaravelDaily
      @LaravelDaily  Год назад +1

      Any PHP variable type or PHP/Laravel class could be a return type. There's no list.

  • @joodjindy318
    @joodjindy318 10 месяцев назад

    thank you so much Sir, i just have a question, you know when we use the 'with' function with a model? it generates two queries, one for the model and one for the relation, can i instruct Laravel to do left join to fetch the data with one query? i don't want to use the query builder too.
    thanks again for all of your work.

    • @LaravelDaily
      @LaravelDaily  10 месяцев назад

      No, it's either query builder with join and one query, or eloquent model with eager loading and two queries.

    • @joodjindy318
      @joodjindy318 10 месяцев назад

      @@LaravelDaily okay, thanks a lot

  • @Ayvengo21
    @Ayvengo21 10 месяцев назад +1

    All the time i see that orm magic like this I'm asking myself does it worth it or maybe some escaped sql would be way easier to read and write. Because sql knowledge could be transferred between projects while knowledge of specific orm might be problematic.

  • @akintandavid2500
    @akintandavid2500 Год назад

    Thanks for this how can i learn more about eager loading

  • @fylzero
    @fylzero 3 года назад +1

    The BelongsToThrough query actually became less efficient, no? It reduced the queries and models used but memory and time to execute increased.

    • @gethermedel3620
      @gethermedel3620 3 года назад

      exactly, it slowed it down but it did simplify the work, so if you're application doesn't require or need the small performance difference, it's a good choice though.

  • @afestacincome2224
    @afestacincome2224 3 года назад +4

    Can you please do a Short video on how to create nested comment and also a Short video on how to retweet a post ( Just like Twitter)

    • @ikarahubs965
      @ikarahubs965 3 года назад +3

      Retweet feature will be nice

    • @niffeydovie4906
      @niffeydovie4906 3 года назад +1

      @@ikarahubs965 nested comment please

  • @erikgratz5539
    @erikgratz5539 2 года назад

    @ 8:00 you are showing off the functionality of `hasManyDeep` to associate employees with their countries. Could this also be achieved with an additional `hasManyThrough` definition? Where it is defined as `hasManyThrough(Employee::class, Shop::class)` ? Or do those methods not chain well / is this strictly better for performance?

  • @programadorweb8403
    @programadorweb8403 2 года назад

    good work!!!

  • @renwar
    @renwar 3 года назад

    Very helpful video.
    Why laravel framework does not have these kind of relationships yet?

    • @LaravelDaily
      @LaravelDaily  3 года назад

      You're free to submit pull requests to the framework and add it.

  • @claudiomenares4172
    @claudiomenares4172 11 месяцев назад

    Muchas gracias 🤯

  • @Raftor74
    @Raftor74 3 года назад +1

    Awesome!

  • @LoveLife-boy
    @LoveLife-boy Год назад

    very well. thank you.

  • @dApoTB
    @dApoTB 3 года назад +3

    Thanks for your videos! Could you please do one about constructing relationships between tables that are in different databases and connection names to those tables cannot be hard coded. E.g.: User table is in DB1, Post table is in DB2 and Comment table is in DB3. Can we construct a relationship here? Thanks!

    • @SonsParaRelaxar
      @SonsParaRelaxar 3 года назад

      It will work the same, the only thing you will have to do is overwrite the connection variable inside of the model.

  • @TechITWorld
    @TechITWorld 2 года назад

    Could you make one video of belongstomany with three level deep query with where condition (with the last one)?

  • @ahmedsyam
    @ahmedsyam 3 года назад

    Good job!

  • @taghreedomer6208
    @taghreedomer6208 2 года назад

    really helped me with retrieving data, but what about insert data? is it possible to do so?

  • @joshbarros1995
    @joshbarros1995 3 года назад +1

    This is cool!!!

  • @danielakintola8000
    @danielakintola8000 2 месяца назад

    This is all nice but the same thing can be achieved with php arrays if you know how.

  • @my_religion
    @my_religion 2 года назад

    Pretty helpful!

  • @insider-analyst
    @insider-analyst 3 года назад

    composer require staudenmeir/belongs-to-through:"^2.5"
    not installing on laravel 8

  • @shofada
    @shofada 3 года назад

    Thanks or putting this together. If you had a page that needs to display say for every employee, the country, city and shop, what might the query look like?

  • @YT-Gmailer
    @YT-Gmailer 3 года назад

    Thank you!

  • @ts.subramanipaiduthaly2038
    @ts.subramanipaiduthaly2038 3 года назад

    Bro, if possible all your future video please make very big fonts and alsp zoom abit because when we use phone its hard to see. It cause not complete watch

  • @gloriaordiz5924
    @gloriaordiz5924 Год назад

    Please make a video about this package belongstothrough

    • @LaravelDaily
      @LaravelDaily  Год назад

      That package has a very good documentation, not sure why the video is needed

  • @muditgulgulia5350
    @muditgulgulia5350 3 года назад

    Best video. 👌

  • @amgadalwattar2863
    @amgadalwattar2863 2 года назад

    very helpfull
    thanks

  • @rishabhandari2501
    @rishabhandari2501 3 года назад

    Helpful 🙌🖤

  • @hungnguyenthanh8189
    @hungnguyenthanh8189 3 года назад

    It’s really helpful. Thank you so much. But if a table has the large data ( about 10.000 record and more) and I use eloquent to find a data. Is it great?. Or I must use DB query?. Please help me that quenstion!

    • @LaravelDaily
      @LaravelDaily  3 года назад +1

      It depends, you need to debug different options and measure performance.

    • @hungnguyenthanh8189
      @hungnguyenthanh8189 3 года назад

      Pardon! Could you explain it more directly?. I have been meeting about 30.000 records to query. I want to count some fields in that table. Does Eloquent still bring good performance?.

    • @LaravelDaily
      @LaravelDaily  3 года назад +2

      Eloquent can or cannot bring good performance, even on million records.
      The performance is not from Eloquent itself, it's from the exact query or statement you write.

    • @hungnguyenthanh8189
      @hungnguyenthanh8189 3 года назад

      I got it. Thank you so much !!

  • @rdvr
    @rdvr 3 года назад

    Brilliant!

  • @salimtheone
    @salimtheone 2 года назад

    how can we select only some attributes of the second table?

  • @alikaram98
    @alikaram98 3 года назад

    Thank you

  • @kingstalker
    @kingstalker 3 года назад

    Thank you
    I have a quistion
    I understand a for each loop ($example as $key) but I don't understand this one
    Can you make a video explaining when to use a foreach ($example as $key => $value)

    • @renwar
      @renwar 3 года назад

      This is basic php foreach loop.
      $key will give you index/key of the array
      $value will give you value of the key
      In some cases you will need the index thats why extending the foreach for key/value

    • @kingstalker
      @kingstalker 3 года назад

      @@renwar thank you i think i understand now lol

  • @devsun9063
    @devsun9063 3 года назад

    Thanks 🙏

  • @chibuikeumezinwa7827
    @chibuikeumezinwa7827 3 года назад

    Lovely!

  • @razin223
    @razin223 3 года назад

    You do not show how to set search filter with "with" relation and its deep level with multiple column. Can you do that?

  • @NazmulHaqueroton
    @NazmulHaqueroton 3 года назад

    Sir, @LaravelDaily If i want to add another table: shop_branches fields: 1) id 2)shop_id 3) shop_branch_name
    then how i define relationship to access: shop_branch_name

  • @mostafamahfouz1139
    @mostafamahfouz1139 3 года назад

    thanks a lot

  • @ekselyum34
    @ekselyum34 3 года назад

    Thanks 👏

  • @RANJEETKUMAR-wz4dg
    @RANJEETKUMAR-wz4dg 3 года назад

    amazing thanks

  • @patihuuu6288
    @patihuuu6288 3 года назад

    What about A -> many to many -> B belongs to -> X, is possible using this package to access X from model A ?

  • @ramdhannugraha99
    @ramdhannugraha99 2 года назад

    how to get all data of that relationships not through some. ex all countries, and all cities and all shop in 1 query, i wanna make tree.. pls advice sir

  • @developer_sagor
    @developer_sagor 3 года назад

    thank you very much

  • @fuhfaysal
    @fuhfaysal 2 года назад

    awesome!!

  • @admireANANTH
    @admireANANTH 3 года назад

    Hey, When can we expect Flutter updates?

    • @LaravelDaily
      @LaravelDaily  3 года назад +1

      In September.

    • @admireANANTH
      @admireANANTH 3 года назад

      @@LaravelDaily Looking forward to it very eagerly bro

  • @juanalbertoacunasilvera6775
    @juanalbertoacunasilvera6775 8 месяцев назад

    someone can tell me the extension for see laravel debugs in window conmsole? 8:30 thanks!

    • @TalesGrechi
      @TalesGrechi 6 месяцев назад

      It's not an extension. It's a package called laravel debug bar!

  • @bimasaktikr
    @bimasaktikr 3 года назад

    helo sir, thanks for the video. may i ask you about extension you use for Visual Code? it help me understand the code better, i really need that extension.

    • @LaravelDaily
      @LaravelDaily  3 года назад

      I don't use Visual Code, I use PhpStorm.