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

Поделиться
HTML-код
  • Опубликовано: 18 мар 2016
  • 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: 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.
    Build a complete Social Network Web Application with PHP Laravel. In this video you will see how file upload in Laravel works and how we can use it to store an user image.
    More on storage in Laravel: laravel.com/docs/5.2/filesystem
    Complete source code: github.com/mschwarzmueller/la...
    You can follow me on Twitter (@maxedapps), Facebook ( / academindchannel ) or visit our Website (www.academind.com).
    See you in the videos!
  • НаукаНаука

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

  • @reignxd6249
    @reignxd6249 7 лет назад +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!

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

      That's really great to hear, as this always was my goal. So happy to have you on board! :)

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

    Thank you so much! :)

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

    Hi body, thank you for nice ( and free :D ) turtorials .
    it's very helpful. Hope you'll get many more views & subscribes

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

      +Rio Blaziken
      Thank you, I sure hope so, too ;)

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

    thank you so much !!

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

      +mehdi lamaafar
      I'm very happy you're liking it!

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

    great! thanks!

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

      Happy to read that you're liking it! :)

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

    thank you much!!!
    pls tutorial website photo gallery with laravel

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

    Thanks for the tutorials. it helped me alot. Can i suggest tutorial to add comment in the post? :D thanks

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

      Thanks for your great feedback and suggestion. I won't add it to this series but I wouldn't rule out a Social Network 2.0 ;-)

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

    I did according to the video but mu likes table in DB is not getting updated whereas I am not getting any changes when I click Like/Dislike in the dashboard view. Looking for kind support.

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

    i have 500 error in line
    $like = $user->likes()->where('article_id', $article_id)->first();
    and returned that Call to undefined method Illuminate\Database\Query\Builder::likes

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

    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!

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

    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.

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

    I really don't know why, whatever if i have already check the code 4 times, but it's not deleting the row in database, just add a news :(

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

    ¡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

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

      Now tell me: Uncaught ReferenceError: urlLike is not defined app.js: 9

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

    I've different postId than yours, , that postId is in a foreach loop, how can I get that postId

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

    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.

    • @LucasRodrigues-oh1jt
      @LucasRodrigues-oh1jt 7 лет назад

      Thank you very much my friend, I read every other comment here and none of them gave me a solution. Yours worked.

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

      np man, I still never got that database migrater to work. I haven't tried it on another machine though, it may be a glitch in installation.
      Deleting the database is only a viable solution if you don't have real data, so I need to figure something out.

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

    Is it possible to teach making groups and pages in the future?
    And thank you so much :)

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

      +CX6998
      Hm, I'll see. Generally I plan to finish this series soon, but of course there will always be new videos/ series to come :)

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

    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.

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

      You can find my code in the Github repo linked in the video description. Make sure to compare your code with mine there - you most likely have some tiny mistake somewhere. Telling by your error description you may find it in the Controller.

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

      Thanks so much. I had a misspell in my ajax call. Gracias

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

    Is there any reason why you use postId instead of post_id in the javascript file? In general I notice you using camelCase in the js files. Just curious.

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

      I use camelCase in all JS code I write, that's true. The reason for that simply is, that most JS frameworks projects use this syntax

  • @anasboumali2519
    @anasboumali2519 7 лет назад +4

    now i know why facebook discarded dislike button =D , mercii

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

      :D

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

      Yeah dislike button just sucks :/ there is no point of putting such button and letting haters shine :P

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

    hello after follow this video i have problem, jquery.min.js:4 POST localhost:8000/like 500 (Internal Server Error) please help me so give me solution ,thanks

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

    $is_like = $request['isLike'] === 'true'? true: false;
    instead of
    $is_like = $request['isLike'] === 'true';
    worked for me.

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

    off topic..do u use green screen while filming?

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

      Yep, I do edit it out via After Effects

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

    I have followed your video tutorial till here , but Iam getting this error " jquery-3.1.1.min.js:4 POST localhost:8000/like 500 (Internal Server Error) " , could you please tell me where is the exact error?

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

      I got the same error. Let me know if you find a solution to the problem Thanks

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

      ahh so i figured out that for me I forgot to add
      public function likes() {
      return $this->hasMany('App\Like');
      }
      into the User.php file

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

      thank so much.

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

    I am getting this error :
    MethodNotAllowedHttpException in RouteCollection.php line 218:
    required help..

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

      Did you compare your code to mine (link in video description => pick the right branch)? Might be some incorrectly set up route or something like that

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

      yes compared. Thanks, finally resolved the errors.

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

      Hi men, how you fix the error? I've the same error, and, I've the same code; so, I don't know what happened there!

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

    I get this error. I even copied your exact code and replace with mine but same problem. jquery-3.1.1.min.js:4 POST localhost:8000/like 500 (Internal Server Error)

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

      OK SOLUTION I did not add the | use Illuminate\Support\Facades\Auth; So it was returning a null attempting to load the Auth::user();

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

      i have the issues and still get the error can you help me ?

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

      Did u fix it. If not are you getting the same error?

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

    plz make this video tutorial in laravel 7

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

    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 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?

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

      Never mind...was missing a damn semicolon... :(

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

      +Dimitri136
      It's always tiny errors like these ;) Happy to hear it's working now!

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

    i don't know why i get the 500 internal server error ! can you help me?

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

    Hi,
    I get this error when I use ajax with laravel
    POST localhost:8000/users/delete 500 (Internal Server Error)
    Can you help me please ?

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

      +ISSAM MOUSLEH
      This means that something went wrong on the server, hence it's no issue with the JS code. You can see a "real error message" by opening your developer tools and navigating to the "network" tab (in Chrome at least). There you will see all request and the failed ones are red. Once you trigger the event which gives you the above stated error, a new "red request" should appear. Click on it and view the response to see the Laravel error message.
      This will hopefully guide you to the necessary fix, otherwise share it here so that I can have a look at it.

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

      +ISSAM MOUSLEH guy you found the bug ?

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

      Rio Blaziken Hey , It was php error.
      I used "compact" with response like this
      return response(compact('userres'));

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

      Check storage/app/logs/laravel.log for me it was 'Class 'App/Like'' not found, it had to be 'App\Like' instead

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

      Hey @ArtM! You have saved my day. Thank You sooo much.

  • @AwadheshKumar-vb2us
    @AwadheshKumar-vb2us 7 лет назад +1

    Need Help Please,
    I'm following this but my like is not inserting in database, and not getting any error how to do?

    • @AwadheshKumar-vb2us
      @AwadheshKumar-vb2us 7 лет назад

      in my controller MethodNotAllowedHttpException in RouteCotroller.php line 233 error when we use post method in web.php

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

      Hey men, do you fix it? I'm trying to do this, but I got the same error, and I don't know how fix it. please.

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

      You can compare your code with this source code
      github.com/mschwarzmueller/laravel-basics-youtube

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

      you forgot to add-- use App\Like

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

    Thank you so much! :)

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

      I'm glad that my video was helpful to you! :)

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

    thank you much!!!
    pls tutorial website photo gallery with laravel

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

      Got a lot of plans, I'll have to see what I'll do next. Thanks for the suggestion though! :)

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

      thank you.