Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
lahirulhr committed Sep 5, 2023
1 parent 5a08232 commit 2959504
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 2 additions & 3 deletions src/Traits/Liker.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
namespace Overtrue\LaravelLike\Traits;

use Illuminate\Contracts\Pagination\Paginator;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Pagination\AbstractCursorPaginator;
use Illuminate\Pagination\AbstractPaginator;
use Illuminate\Support\Collection;
use Illuminate\Support\LazyCollection;
use Overtrue\LaravelLike\Like;
use Illuminate\Database\Eloquent\Casts\Attribute;

trait Liker
{
Expand Down Expand Up @@ -137,12 +137,11 @@ public function attachLikeStatus(&$likeables, callable $resolver = null)
throw new \InvalidArgumentException('Invalid argument type.');
}
}

protected function totalLikes(): Attribute
{
return Attribute::make(get: function ($value) {
return $this->likes()->count() ?? 0;
});
}

}
2 changes: 1 addition & 1 deletion tests/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

class User extends Model
{
use Liker;
use Likeable;
use Liker;

protected $fillable = ['name'];
}

0 comments on commit 2959504

Please sign in to comment.