vendredi 23 octobre 2020

How to remove paginate in Laravel?

I need to remove the pagination and leave everything on one page, but this way I'm doing it only generates BUG. I wonder why the snippet of the commented code doesn't work to remove the pagination.

    if ($minParam || $maxParam) {
      $products = Product::whereHas('sizes', function ($query) use ($minParam, $maxParam) {
        if ($minParam && $maxParam) {
          $query->whereBetween('max_capacity', [$minParam, $maxParam]);
        } elseif ($minParam) {
          $query->where('max_capacity', '>=', $minParam);
        } else {
          $query->where('max_capacity', '<=', $maxParam);
        }
      })
        ->whereHas('solutions', function ($query) use ($solution_id) {
          $query->whereIn('solution_id', $solution_id);
        })
        ->where('active', 1)
        ->orderBy('position', 'ASC')
        ->paginate(16);
    } else {
      $products = Product::whereHas('solutions', function ($query) use ($solution_id) {
        $query->whereIn('solution_id', $solution_id);
      })
        ->where('active', 1)
        ->orderBy('position', 'ASC')
        ->paginate(16);

 /*$products = Product::whereHas('solutions', function ($query) use ($solution_id) {
    $query->whereIn('solution_id', $solution_id);
  })
    ->where('active', 1)
    ->orderBy('position', 'ASC');*/
    
      return view('solutions.show')->with(compact('solutions', 'solution', 'products', 'ranges'));
    
    }

The bug after replacing with get ()

public function __call($method, $parameters)
    {
        if (! static::hasMacro($method)) {
            throw new BadMethodCallException(sprintf(
                'Method %s::%s does not exist.', static::class, $method
            ));
        }
 
        $macro = static::$macros[$method];
 
        if ($macro instanceof Closure) {
            return call_user_func_array($macro->bindTo($this, static::class), $parameters);
        }
 
        return $macro(...$parameters);
    }
}


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire