Example of Local scopes in bytefury/crater

File app/Models/PaymentMethod.php (link to Github)
use Illuminate\Database\Eloquent\Model;

class PaymentMethod extends Model
{
    //
    public function scopeWhereCompany($query, $company_id)
    {
        $query->where('company_id', $company_id);
    }
    //
}
File app/Http/Controllers/V1/Payment/PaymentMethodsController.php (link to Github)
use Crater\Http\Controllers\Controller;
use Crater\Models\PaymentMethod;
use Illuminate\Http\Request;

class PaymentMethodsController extends Controller
{
    public function index(Request $request)
    {
        $limit = $request->has('limit') ? $request->limit : 5;

        $paymentMethods = PaymentMethod::whereCompany($request->header('company'))
            ->applyFilters($request->only([
                'method_id',
                'search',
            ]))
            ->latest()
            ->paginateData($limit);

        return response()->json([
            'paymentMethods' => $paymentMethods,
        ]);
    }
    //
}

Additional resources on local scopes: