Laravel Gems - Once 💎

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

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

  • @anthonyjamesaliduh7525
    @anthonyjamesaliduh7525 4 месяца назад +6

    Impressive! But I'm kinda curious, why having to wrap the query to get featured post in a resolve( ) - > handle() function? Please someone school me, what does that achieve when I can simply do Post::where('featured', 1) -> get()

    • @spicynoodle7419
      @spicynoodle7419 4 месяца назад +1

      This is a long conversation. I suggest you check Spatie's book "Laravel beyond CRUD"

    • @prashank
      @prashank 4 месяца назад +1

      resolve() is useful to initialize a class from the container and get automatic dependency injections. So any type hinted classes on the class being resolved is also resolved by the container and all the way down.

    • @antonmykhailovskyi447
      @antonmykhailovskyi447 4 месяца назад +1

      Even though this example is not showing it super right, that is about SOLID. This is really deep topic, so you have to dive into this by yourself. There is a bunch of information about it though

    • @LaravelPHP
      @LaravelPHP  4 месяца назад +1

      Good question. There are already some good replies too, but yeah you could write it like you do too. But sometimes getting featured posts is not that easy and you need to perform maybe multiple queries to find them. For bigger apps there might a lot of business logic to define that. Hope that helps 👍

    • @anthonyjamesaliduh7525
      @anthonyjamesaliduh7525 4 месяца назад

      Thanks for all the responses. I'll definitely check out Spatie's book on this same subject and also study more about SOLID principles as recommended. Thanks all, Laravel ❤️❤️❤️

  • @orpheusohms
    @orpheusohms 4 месяца назад +2

    Great one, but I'm foreseeing an issue with Octane

    • @fransslabbekoorn
      @fransslabbekoorn 4 месяца назад +2

      Laravel octane handles this by flushing the instance after the operation is terminated using the FlushOnce class

  • @eduardodallavecchia5991
    @eduardodallavecchia5991 4 месяца назад

    This is awesome, I've wrote something similar too many times to count for some static cache, using a helper is definitely smarter

    • @LaravelPHP
      @LaravelPHP  4 месяца назад +1

      That's awesome! Glad you like it!

  • @uniqueprogramming5299
    @uniqueprogramming5299 4 месяца назад

    This is a great feature. But if its support a 2nd parameter and it will cache base on that cache that would be amazing something like react useEffect hook.

  • @chriram2464
    @chriram2464 4 месяца назад

    Definitely a very good feature - at the same time, I hope it doesn't make people too lazy to check when something is accessed.

  • @krishnaagrawal441
    @krishnaagrawal441 4 месяца назад

    I love it 👍🏻👍🏻

  • @dominikbetlej1656
    @dominikbetlej1656 4 месяца назад +1

    Thx!

  • @srhanzd3022
    @srhanzd3022 4 месяца назад

    😍😍😍

  • @Noum77
    @Noum77 4 месяца назад

    I'm happy this is now a built-in

  • @ladenbin
    @ladenbin 4 месяца назад +2

    I said it Once and ill say it again. The real gems are the Laravel friends we made along the way.

  • @khanra17
    @khanra17 4 месяца назад

    You need a better host.
    Who has the same energy as Laravel.