Organizing data with Laravel Collections

Поделиться
HTML-код
  • Опубликовано: 13 июл 2024
  • In this 32 minute video, I'll show you 12 examples using Laravel Collections that you can use to organize, sort, and filter your large or complex data sets.
    You'll learn how to:
    - Set up a basic Laravel 8 project
    - Use Laravel's HTTP library to pull in JSON from Reddit
    - Filter and organize a large data set with a variety of collections
    - Maximize code efficiency and readability
    - 0:00 Intro
    - 00:34 Project Setup
    - 06:06 Filter Method
    - 09:02 Pluck Method
    - 11:00 Contains Method
    - 13:28 GroupBy Method
    - 17:18 SortBy Method
    - 19:06 Partition Method
    - 22:40 Reject Method
    - 24:16 WhereIn Method
    - 25:38 Chunk Method
    - 27:22 Count Method
    - 28:30 First Method
    - 30:22 Tap Method
    - 32:18 Conclusion
    Follow me on Twitter! / aschmelyun
  • НаукаНаука

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

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

    Your tuts are of great style and pace and are very helpful for me as a relative Laravel newbie. Thank you.

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

    Fantastic! Best tutorial on collections I’ve seen

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

    This is an amazing tutorial. I've watched several tuts on Collections but this stands out for me. Awesome Tut, Awesome Example. Awesome Pace.
    Thank you Andrew

  • @JohnSmith-zl8rz
    @JohnSmith-zl8rz 3 года назад +1

    This channel needs more views and more videos. Thanks.

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

      Thank you! I'm working on getting there, haha.

    • @JohnSmith-zl8rz
      @JohnSmith-zl8rz 3 года назад

      @@aschmelyun I know, I bet you have a real world job and this tuts are an extra, you teach so well, I bet if you make complete series you will get tons of views.

  •  3 года назад

    Very cool. Thanks for sharing!

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

    Great quality content

  • @thebirdhasbeencharged
    @thebirdhasbeencharged 3 года назад +6

    Video on your phpstorm setup

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

    Great info.

  • @user-zs3hl8ze9j
    @user-zs3hl8ze9j 6 месяцев назад

    Great Work
    thank u
    go ahead

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

    Love this wow

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

    Nice thank you

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

    thanks tons...

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

    thanks for sharing

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

    amazing

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

    I hope you can make videos related to laravel CI/CD

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

    Can you make an example with foreign tables queries on livewire? I have an example that I'm struggling with

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

    Which editor you are using and which plugins ?

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

    Why do you initialize a PRIVATE property through the controller CONSTRUCTOR for the index method?

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

      Because the constructor is always called to initialize the controller class. That way, he doesnt have to initialize it on all the other methods.

  • @josuebarros-desenvolvedorw2490
    @josuebarros-desenvolvedorw2490 3 года назад

    So... if I get some Real Estate data coming from a external api (json), convert into a Laravel Collection I can paginate the results with pagination method?

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

      Good question. Did you hack this? Been struggling with the same. After converting Odata to collection how do you paginate without first saving to db table

    • @josuebarros-desenvolvedorw2490
      @josuebarros-desenvolvedorw2490 2 года назад

      @@stephenmcatieno3849 hmmm, I don't quite remember because its been a while... since I hit apis with ReactJS now, I can get the results and modify in any format using javascript functions

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

    Some objects in the collection don't have the post_hint key anymore which causes it to return an error: Undefined array key "post_hint"

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

      Ah, thanks for letting me know!

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

      @@aschmelyun Please can you help me / us with a solution as to how to get around the problem Undefined array key "post_hint" with collections filter method. I am struggling to find a solution for days now.

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

    Please start laravel project

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

    I am not seeing your result. From the filter method I get ErrorException undefined array key "post_hint". I am using Laravel 10?

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

      Hi there. I found the solution - I think: public function filter()
      {
      $posts = $this->posts->filter(function($post, $key) {
      if( empty($post['data']['post_hint'])) {
      return false;
      }
      return \Illuminate\Support\Str::contains( $post['data']['url'], 'i.redd.it');
      });

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

    what is dcr?

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

      He uses Docker. so it's a docker specific command not Laravel. Can't remember, he's talked about it before.

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

    Okay, better tell us all about your keyboard now mister.

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

    too fast

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

    Hi here is the work I put in for pluck. Seems to be working. 1. declare $images at top of controller then public function pluck()
    {
    $images = $this->posts->filter(function($post, $key) {
    if( empty($post['data']['post_hint'])) {
    return false;
    }
    return \Illuminate\Support\Str::contains( $post['data']['url'], 'i.redd.it');
    })
    ->pluck('data.url')
    ->all();
    return view('collections.pluck' , [
    'images' => $images
    ]);
    }
    2. In pluck.blade.php @foreach($images as $image) blabla blabla@endforeach