[Vuejs]-Laravel ::when on paginate, length undefined

0👍

This should work:

 $term = 10;
    $query = Group::where('company_id', Auth::user()->company_id)->when($request->search, function($query,$term){
        $query->where('code', 'LIKE' , '%' . $term. '%')
            ->orWhere('name', 'LIKE' , '%' . $term. '%')
            ->orWhere('description', 'LIKE' , '%' . $term. '%');
    })->when($request->column, function($query, $term) use ($request){
        $query->orderBy($term, $request->order);
    });
    if(request()->size != null) {
       $term = (int)request()->size;
    }
    $query = $query->paginate($term);

Leave a comment