Laravel 5.2 PHP Build a social network - Likes & Dislikes (1/3 - Models & AJAX)

Поделиться
HTML-код
  • Опубликовано: 16 мар 2016
  • Build a complete Social Network Web Application with PHP Laravel. This videos shows to start with the implementation of a Like/Dislike mechanic by setting up the backend and configuring the AJAX call.
    Complete source code: github.com/mschwarzmueller/la...
    Complete Laravel-course on Udemy: www.udemy.com/modern-web-deve... (Coupon: RUclips1)
    In this course we'll build a neat little social network and cover the basics of developing with Laravel.
    You can follow me on Twitter (@maxedapps), Facebook ( / academindchannel ) or visit our Website (www.academind.com).
    See you in the videos!
  • НаукаНаука

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

  • @JackFruh
    @JackFruh 8 лет назад +2

    This is OVER THE TOP!
    Fantastic job! Love the greenscreen overlay - being able to see a person talk when they talk for a while really helps keep the focus!.

    • @academind
      @academind  8 лет назад +1

      +Jack Fruh
      Hi Jack, I'm very happy you're liking the format. I also helps me to explain things better and it feels more like actually talking to someone than just talking to the laptop ;)

  • @GravityGamingCo
    @GravityGamingCo 8 лет назад +3

    Great video as always. You are the best laravel teacher on the internet hands down.

    • @academind
      @academind  8 лет назад

      Wow, amazing to hear this, many, many thanks! :)

  • @slowly065
    @slowly065 8 лет назад

    I'm very Thankful for your explanations, keep doing it and i will allways appreciate the help. Thank you dude.

    • @academind
      @academind  8 лет назад

      +Pedro Lugo
      Thank you Pedro, I'll certainly keep the videos coming! :)

  • @uzayyolcusu-uzaylbaksyalnz9959
    @uzayyolcusu-uzaylbaksyalnz9959 3 года назад

    I like your teaching style based on a story of every single detail. Keep going on. Regards

  • @ahmedwahba6681
    @ahmedwahba6681 8 лет назад

    Great job!
    thank you very much :)

  • @Dylan-oh5ii
    @Dylan-oh5ii 7 лет назад +1

    Haven't worked ahead too much in the like videos, just wanted to say that I chose to make the tags in the dashboard view "like" and "dislike". This way, if I happen to want to modify the the code or put the "like" and "dislike" buttons in a different place, it will be more dynamic than hardcoding them to recognize if it the first element in the list, like he did in this video.
    Personal preference, but I prefer to take the extra steps to make things dynamic to save the possibility of extra work (or confusion of why you broke something) down the line.

  • @shi1873
    @shi1873 8 лет назад

    thank you! It's easy learning this from you XD

    • @academind
      @academind  8 лет назад

      +Sheila Clitar
      Great to hear that! :)

  • @pawlowss
    @pawlowss 7 лет назад +1

    I'd say it's preferrable not to rely on the DOM structure too much IRL because it can change quite a bit as an application evolves over time. For identifying the like/dislike links, using a data attribute for example would be more robust.

  • @user-wf5jv1me2b
    @user-wf5jv1me2b 4 года назад

    Дуже дякую !!

  • @ayaayari5666
    @ayaayari5666 8 лет назад +1

    thank you :D

    • @academind
      @academind  8 лет назад

      +Aya Ayari
      Happy to see you're liking it! :)

  • @rebeccal7704
    @rebeccal7704 8 лет назад

    Hi Max, if i want to make a save button for save the post the user interesting in, I think I can apply the similar method as the likes and Dislikes. But the save function should only have one button how to code my Ajax??

    • @academind
      @academind  8 лет назад

      +Rebecca Lau
      Hi Rebecca, I'm not sure if I understand you correctly. The AJAX request would probably send the post_id to the server and it would of course be triggered upon button hit.

  • @maruatajongte6293
    @maruatajongte6293 6 лет назад

    How can we have up voting and down voting system using laravel

  • @JoelJosephReji
    @JoelJosephReji 6 лет назад

    Hey, which was the text editor you were using?

    • @academind
      @academind  6 лет назад

      It's PHPStorm in this video

    • @JoelJosephReji
      @JoelJosephReji 6 лет назад

      Academind, thank you for the info

  • @dots1p
    @dots1p 8 лет назад

    Would it be possible to somehow store session info (or something) instead of user_id ? This to enable anyone to "heart" an article, comment, etc. but in the same time disable him to mess up with the button clicking it randomly over and over again ... at least while in the same session.

    • @academind
      @academind  8 лет назад

      You mean store session id in the database? I would rather simply implement a check based on the fact if the userlikepost connection already exists. That would also prevent multiple likes.

    • @dots1p
      @dots1p 8 лет назад

      I've sent you an email about the whole problem so if you have time, it would be great if you check it out. :)

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

    I have problems with getting postId cause it's from the edit video & i didn't watch it

  • @mehdilamaafar5823
    @mehdilamaafar5823 8 лет назад

    thank you for the tutorial. and are you sick?

    • @academind
      @academind  8 лет назад

      +mehdi lamaafar
      Yes, during the recoding of this video I was sick. I tried to cut out all sniffing etc. but I apologize if it's still hearable.

  • @dgaborus
    @dgaborus 6 лет назад

    Why would you do these foreign-key relations in code? Why not use Workbench?

  • @agilasadi5044
    @agilasadi5044 7 лет назад +1

    I still dont understand what excatly we r doing in these Like.php User.php and Post.php .
    I understand It a bit but a little explanation would rly help me out.

    • @ThabangBosaka
      @ThabangBosaka 7 лет назад

      Hey man, i did like and dislike button, when a user press one of them, i then call js function, that function will communicate with my php file using ajax, then i update a table where i store Likes and dislike counts; in your php you have to check if its a duplicate or new like or dislike, after you update the table, then reload the Like and Dislike count in your view

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

    Kindly do this with livewire

  • @manjunathm4704
    @manjunathm4704 7 лет назад

    Hello sir,How can count i count likes for perticuler post,
    thnk you

    • @ironer100
      @ironer100 7 лет назад

      You can use something like this: public function getNbLikesAttribute(){return $this->hasMany('app\Like')->count();}

  • @vikramshaw1908
    @vikramshaw1908 8 лет назад

    I followed your series and it is very good but I'm facing a problem that when I'm clicking on like/dislike nothing is happening and the data are not being store. When I checked in console then it is showing this error "POST localhost:8000/like 501 (Not Implemented)". Can you help me with this. Thank you.

    • @academind
      @academind  8 лет назад

      Hi Vikram, this indicates that there is a an error in your Laravel code. You may click on the erroneous request in the developer tools and you should be able to view the actual response Laravel sent. There, you should see a better error message, explaining what went wrong in your server-side code

    • @vikramshaw1908
      @vikramshaw1908 8 лет назад

      Thank you sir for the quick reply. But the thing is I'm very new to this Laravel or coding still I'm in learning phase only so can you elaborate a little more about this one "You may click on the erroneous request in the developer tools " so that I can check the errors and I did exactly what you did in this like series. Can you check my codes and tell me where I'm doing error. This one is my like.js file:-- laravel.io/bin/wJzq9 .
      Like.php :-- laravel.io/bin/qQPqV . Migrtaion file:-- laravel.io/bin/0ev9G . This is my FeedsController(Your's PostController): laravel.io/bin/7wv65 . Feed.php :- laravel.io/bin/jQxM9
      User.php:-- laravel.io/bin/8KXz5

    • @academind
      @academind  8 лет назад

      Hi Vikram,
      sorry but I can't do that since you're working on a totally different project. I would have to dig into that first and that simply is a service I can't offer to close to 9.000 subscribers. Simply due to time restrictions.
      What I meant with "click on request" is, that in your developer tools you may visit the "Network" tab (assuming Chrome dev tools, but there certainly is an equivalent in FF). You should see a red request there (the erroneous). Click on it and then you should be able to select "Response" somewhere. There, you should see the Laravel error message, which hopefully gets you on the right track to fix this error.

    • @vikramshaw1908
      @vikramshaw1908 8 лет назад

      Thanks anyways. I can see the source of the errors but as I don't know anything about the AJAX I'm not able to figure out how to solve that error. Thanks anyways for replying.

    • @academind
      @academind  8 лет назад

      But which error message does Laravel give you if you inspect the request (and its response) in the developer tools?

  • @PraveenKumar-ic4ii
    @PraveenKumar-ic4ii 3 года назад

    Where is the web.php file sir?

  • @MrPoymanov
    @MrPoymanov 8 лет назад +1

    You again don't set foreign key for your like migration. I mean this construction:
    $table->foreign('user_id')->references('id')->on('users');
    Why?

    • @academind
      @academind  8 лет назад +1

      +Николай Пойманов
      Because I don't really need it here. But you are of course free to add this constraint.

    • @MrPoymanov
      @MrPoymanov 8 лет назад

      Thx!

  • @equaliserTV
    @equaliserTV 5 лет назад

    krasser Typ.

  • @VBtutorails
    @VBtutorails 8 лет назад

    I'm trying to, instead of putting 'Account' in the navbar, place the users first name. My problem is that the $user variable isn't recognized in 'dashboard.blade.php'. Here's a pastebin.com/aMT1Gwvk with my code (thought it would be easier to read there).

    • @academind
      @academind  8 лет назад

      You need to make sure to pass your data into that view. Make sure you're doing this when return view('dashboard')

  • @TariqAq
    @TariqAq 4 года назад

    The problem with his tutorials is that you can't really pick up much from them unless you watch the entire videos.

  • @borklazer4775
    @borklazer4775 7 лет назад

    >$post>

  • @denissondesouza
    @denissondesouza 6 лет назад

    this guy is a good teacher but gosh he talks waaaay too much

  • @borklazer4775
    @borklazer4775 7 лет назад

    > $post>