Ty man, i have been stuck for weeks because of that, it wasnt working until you wrote to took out the ->exists();
same thing to delete, the result is: $likeable->likes()->whereHas('user', function(Builder $query) { $query->whereId($this->id); })->delete();
$likeable->likes()->whereHas('user', function(Builder $query) { $query->whereId($this->id); })->delete();
Also, if someone implements this, dont forget to add this in Likes.php use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Builder;
Yeah I removed the Builder typehint, it wasn't very helpful anyway.
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Ty man, i have been stuck for weeks because of that, it wasnt working until you wrote to took out the ->exists();
same thing to delete, the result is:
$likeable->likes()->whereHas('user', function(Builder $query) {
$query->whereId($this->id);
})->delete();
Also, if someone implements this, dont forget to add this in Likes.php
use Illuminate\Database\Eloquent\Builder;
Yeah I removed the Builder typehint, it wasn't very helpful anyway.