Laravel 5.2 PHP Build a social network – Likes & Dislikes (2/3 – Finishing the Backend)


Video is ready, Click Here to View ×

Build a complete Social Network Web Application with PHP Laravel. In this video we finish the backend of our Like/Dislike feature by setting up the route and the controller as well as by implementing the database operations.

Complete source code:

Complete Laravel-course on Udemy: (Coupon: YOUTUBE1)

In this course we’ll build a neat little social network…

28 thoughts on “Laravel 5.2 PHP Build a social network – Likes & Dislikes (2/3 – Finishing the Backend)

  1. For your 4th case, the one when the logged in user clicks DISLIKE: you said to UPDATE the row, and INSERT 0 into the like column; but what if there is no row already in db? There will be no row to be updated. So I think you need extra logic in the controller: check whether the row exists: and if it does exist then UPDATE it with like=0, and if it doesn't exist then INSERT a new one with like=0.

  2. ¡Buenos días! curso muy bueno! No puedo cargar el PP le gusta copiar el mismo repositorio de código de esa cantidad las mismas bibliotecas, etc. y no ejecutar la función, que puede ser? Desde ya muchas gracias! @Mindspace

  3. Just wanted to share an error I encountered.
    If you are getting a 500 Server error, try deleting all of the tables in your database (the actual database itself, not the migration files or any code) and then running the artisan migrate tool.
    For some reason, it is not properly migrating my tables for me when I update them, but deleting the existing tables in the database and re-migrating them does the trick.

    If anyone has any idea of how to fix this, let me know. It isn't a problem now, but later on if I want to add functionality to an existing model and I have many entries, it would be troublesome.

  4. i really love how the way you explain all those things in laravel. keep all the explanation simple, so a beginner like me can understand. i'm so thankful, keep posting! this channel really derserves more subscriber!

  5. Hi Max, I'm getting this Error: Creating default object from empty value in PostController.php line: $like->like = $is_like;
    Do you maybe know how to fix this problem?
    thanks in advance for the help and for the great tutorials!

  6. Hello there Thanks for these amazing series I am facing a problem , have the same codes but no data is being inserted into my likes table. My ajax is posting fine but no insertion into the table.

  7. Hi! So I'm having issues in the PostController and if found out that the error comes from this line:

    $like = $user->likes()>where('post_id', $post_id)>first();

    for some mysterious reasons I cannot get the Likes of the user. On my javascript console I get this error:

    >> POST http://localhost/lsocial/public/like 500 (Internal Server Error)

    Which doesn't really help.

    I've checked my classes and all the relations seem correct. I did some tests and the relations between users and posts work fine, but for some reasons I get this problem when it comes to relations between users and likes or posts and likes. Any suggestion?

Leave a Reply

Your email address will not be published. Required fields are marked *