Laravel Scope get request data/param
Laravel scopes are not a way to create static methods, they should be used to add parts to a database query. They should always return a query builder.
Aim to make your scopes as small as possible so you can then combine them together to make more complex queries.
It doesn't matter if you use the Request passed in to the controller or the request() helper, use whichever you prefer.
If you aren't going to reuse the getSelect2() method you don't need to add it to the model, just do the query in the controller. If you do need to repeat the query elsewhere you can make a new class that can build the options ($formatted_tags).
class Customer extends Model
{
    // ...

    public function scopeNameLike($query, $name): void
    {
        $query-&gt;orderBy('name','asc')-&gt;where(&quot;name&quot;, &quot;like&quot;, &quot;%{$name}%&quot;);
    }

    // ...
}

class Controller
{
    public function selectJson(Request $request)
    {
        return Customer::nameLike($request-&gt;q)
            -&gt;when($request-&gt;city_id, function ($query, $value) {
                $query-&gt;where('city_id', $value);
            })
            -&gt;limit(5)
            -&gt;get(['name', 'id'])
            -&gt;map(function ($item) {
                return ['id' =&gt; $item-&gt;id, 'text' =&gt; $item-&gt;name];
            });
    }
}



Is return something in scope really bad practice? What about the normal method in the model? I have so many tables/models that I need to format to select2 format. Am I need to format it in every controller? – Muhammad Dyas Yaskur

I was mistaken that scopes shouldn't return a value, as per the Laravel documentation they should return a query builder instance. It would be bad practice to return any other value from a scope.
If you need many of these types of queries for different models you can create a helper class that can then be reused.
class Select2
{
    public static function customer(Request $request)
    {
        // Query moved from controller
    }
}

class Controller
{
    public function selectJson(Request $request)
    {
        return Select2::customer($request);
    }
}