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! Наука
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!
That's really great to hear, as this always was my goal. So happy to have you on board! :)
Thank you so much! :)
Hi body, thank you for nice ( and free :D ) turtorials .
it's very helpful. Hope you'll get many more views & subscribes
+Rio Blaziken
Thank you, I sure hope so, too ;)
thank you so much !!
+mehdi lamaafar
I'm very happy you're liking it!
great! thanks!
Happy to read that you're liking it! :)
thank you much!!!
pls tutorial website photo gallery with laravel
Thanks for the tutorials. it helped me alot. Can i suggest tutorial to add comment in the post? :D thanks
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 ;-)
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.
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
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!
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.
it's already there:)
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 :(
¡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
Now tell me: Uncaught ReferenceError: urlLike is not defined app.js: 9
I've different postId than yours, , that postId is in a foreach loop, how can I get that postId
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.
Thank you very much my friend, I read every other comment here and none of them gave me a solution. Yours worked.
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.
Is it possible to teach making groups and pages in the future?
And thank you so much :)
+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 :)
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.
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.
Thanks so much. I had a misspell in my ajax call. Gracias
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.
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
now i know why facebook discarded dislike button =D , mercii
:D
Yeah dislike button just sucks :/ there is no point of putting such button and letting haters shine :P
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
$is_like = $request['isLike'] === 'true'? true: false;
instead of
$is_like = $request['isLike'] === 'true';
worked for me.
off topic..do u use green screen while filming?
Yep, I do edit it out via After Effects
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?
I got the same error. Let me know if you find a solution to the problem Thanks
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
thank so much.
I am getting this error :
MethodNotAllowedHttpException in RouteCollection.php line 218:
required help..
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
yes compared. Thanks, finally resolved the errors.
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!
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)
OK SOLUTION I did not add the | use Illuminate\Support\Facades\Auth; So it was returning a null attempting to load the Auth::user();
i have the issues and still get the error can you help me ?
Did u fix it. If not are you getting the same error?
plz make this video tutorial in laravel 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 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?
Never mind...was missing a damn semicolon... :(
+Dimitri136
It's always tiny errors like these ;) Happy to hear it's working now!
i don't know why i get the 500 internal server error ! can you help me?
put use App\Like; on top it will work
Thank you! it worked!
You are welcome!!!
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 ?
+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.
+ISSAM MOUSLEH guy you found the bug ?
Rio Blaziken Hey , It was php error.
I used "compact" with response like this
return response(compact('userres'));
Check storage/app/logs/laravel.log for me it was 'Class 'App/Like'' not found, it had to be 'App\Like' instead
Hey @ArtM! You have saved my day. Thank You sooo much.
Need Help Please,
I'm following this but my like is not inserting in database, and not getting any error how to do?
in my controller MethodNotAllowedHttpException in RouteCotroller.php line 233 error when we use post method in web.php
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.
You can compare your code with this source code
github.com/mschwarzmueller/laravel-basics-youtube
you forgot to add-- use App\Like
Thank you so much! :)
I'm glad that my video was helpful to you! :)
thank you much!!!
pls tutorial website photo gallery with laravel
Got a lot of plans, I'll have to see what I'll do next. Thanks for the suggestion though! :)
thank you.