Building a user following / unfollowing system with Laravel and InertiaJS

Поділитися
Вставка
  • Опубліковано 2 жов 2024
  • We have a twitter-like app but no user following/unfollowing system in place. So let’s build it.
    The first thing we’re going to do is create two endpoints and two page components for the followers and followings pages. We’ll add a bit of styling, and then focus on how we can store and query who follows who.
    Sometimes I blog at: tallpad.com

КОМЕНТАРІ • 18

  • @richard_keep
    @richard_keep 3 роки тому +1

    Great video. You can also style the FOLLOWING button in such a way that when you hover the mouse the text changes to UNFOLLOW with a red background.

    • @richard_keep
      @richard_keep 3 роки тому +1

      Please seed the DB with 500 followers and implement an infinite scroll that autoloads new data.

  • @alabaganne3772
    @alabaganne3772 3 роки тому +3

    can you upload source code to github please?

  • @pradeepspace3
    @pradeepspace3 3 роки тому

    Great video Druc

  • @dalivan5119
    @dalivan5119 3 роки тому +2

    Thanks! Go on with the works. Your tutorial are really good but how to check if user is already followed inside user profile page? I use $this->following()->where('follower_id', $user->id)->count(); inside model, doesn't work, please help.

    • @cdruc
      @cdruc  3 роки тому +1

      Hey!
      It's been a while since I recorded the video, but I guess you could do something like: $user->followers()->where('user_id', auth()->id())->exists() - and this will return a boolean saying if that particular user is followed by the authenticated user.

    • @dalivan5119
      @dalivan5119 3 роки тому +1

      @@cdruc The code its work, thanks! I appreciate your time.

  • @yasirarafat-dev
    @yasirarafat-dev 3 роки тому +1

    hello, can you make a detailed video on inertia
    progress indicators?

  • @bentomlin
    @bentomlin 2 роки тому

    When unfollowing someone, it would be better if the person remained afterwards, but with a follow button, so that you can re-follow if you clicked the wrong one. In the example here they disappear because the whole list is re-rendered

  • @mamadoery
    @mamadoery 3 роки тому

    How have you done the sidebar in tailwind, does it have the code somewhere or repository?

  • @mamadoery
    @mamadoery 3 роки тому

    What font do you have installed in VisualCode? Very nice!

  • @suneeilthapa519
    @suneeilthapa519 3 роки тому

    Symfony\Component\Debug\Exception\FatalThrowableError : Call to a member funtion followings() on null [ laravel verion 5.6 ] Please help i got this error while php artisan migrate:fresh --seed

  • @samhk2222
    @samhk2222 3 роки тому

    Man, you're good

  • @saktipujoedi8898
    @saktipujoedi8898 3 роки тому

    Great video

  • @creeddm
    @creeddm 3 роки тому

    Thanks for the video. I wonder if it is possible to recreate UI similar to Reddit with Inertia where you click on the post, it opens in the modal, page URL changes, but posts list stays in the background.

    • @creeddm
      @creeddm 3 роки тому

      I think twitter has the same behavior when you click on some image inside of a post.

    • @cdruc
      @cdruc  3 роки тому +1

      Inertia is not a silver bullet, and it's not particularly good with modals: github.com/inertiajs/inertia/issues/249 (although people are working hard on it).
      But yes, I think the scenario you described could be recreated with Inertia - at least the part with:
      "I'm on a list of posts, clicking on one will bring up a modal and will give me an url I can paste in another window and load the same post modal".
      But once you move to the "I also need to post comments from this modal" - then, you are better off by using a regular xhr.
      The idea is, inertia can help (a lot), but you still have to sprinkle some xhr from time to time :)

  • @mrluxury3480
    @mrluxury3480 3 роки тому

    can you share source code in github?