Laravel: take(1)->count(); what does this mean?

I am studying the source code of a package, rtConner/laravel-tagging. In this package there is a trait called TaggableTrait. On line 179, in a method called addTag(), there is this line which I don’t understand:

$previousCount = $this->tagged()->where('tag_slug', '=', $tagSlug)->take(1)->count();

What does this line do? In specific, my problem is with ->take(1)->count(); part, are we taking 1 of the entries from the where clause and then count it?


Source: laravel

Leave a Reply