laracasts / tweety Goto Github PK
View Code? Open in Web Editor NEWThe final project from Laravel From Scratch.
Home Page: http://laravelfromscratch.com
The final project from Laravel From Scratch.
Home Page: http://laravelfromscratch.com
In the "Build a Like/Dislike system" episode 67 of the series, in 22:23 timestamp, we start including the "like" and "dislike" buttons and im getting a Call to a member function where() on null
this happens after I implement this on the _tweet.blade.php
blade file
<div class="flex items-center {{ $tweet->isDislikedBy( current_user() ) ? 'text-blue-500' : 'text-gray-500' }}">
The error is actually being returned in line 4:
1. public function isDislikedBy(User $user)
2. {
3. return (bool) $user->likes
4. ->where('tweet_id', $this->id)
5. ->where('liked', false)
6. ->count();
7. }
How can I start knowing what's going on in or out from the isDislikedBy()
? What im thinking is that I should be back-engineering the source of that where function because what's inside of it, it's returning null. I noticed jeffrey doesn't ever references a Model, like for example, this: use App\Like
and that happens in most of the files, where as I have had to do that in some Models. I know he's on Laravel 6 and Im wondering if in Laravel 8, the reason why it's returning null is because an endpoint somewhere isn't being referenced. Thanks! Awesome project.
フロントエンド
バックエンド
I've added parent_id to tweets as a means to include tweets as comments too.
I've added a parent() and children() method to the Tweet model
public function children()
{
return $this->hasMany('App\Tweet', 'parent_id')->with('children');
}
But when I add ->withCount('children')
to the timeline() method it foobar's the ->withLikes() method. instead of a number for likes & dislikes I get json string of the likes array instead.
[{"id":1,"user_id":1,"tweet_id":50,"liked":1,"created_at":"2020-10-12T20:24:10.000000Z","updated_at":"2020-10-12T20:27:00.000000Z"},{"id":3,"user_id":2,"tweet_id":50,"liked":1,"created_at":"2020-10-12T20:24:29.000000Z","updated_at":"2020-10-12T20:24:29.000000Z"}]
My questions is, why does this happen? is it someinthg in the Likable trait that doesn't like the withCount or the possiblitiy is nesting? or other?
I know and appreiacite it is a little off-topic so any help would be cool.
This example code produces one sql extra query for each tweet:
select * from "users" where "users"."id" = '1' limit 1
So for many tweets this will kill any database. I understand that this is just a "basic example", but I would say that avoiding unneccessary db queries belongs to the basic teachings that any new developer should learn - it is really important to not teach people wrong things, they will carry on with that for very long and it will hurt them eventually.
It would be great if you would like to add some information to your tutorial about how to cache queries or avoid them - also it will be a good thing for all the db admins around the world to produce new developers that do not produce code like this :) - thank you very much!
Hi,
I'm finding I can't login following registration. would this be a know issues?
Install
Migrate
Register,
Logout
Login > "These credentials do not match our records."
is the validation and/or hasing correct?
*Needless to say that this user is indeed within the database and I am using the correct details.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.