Ejemplo n.º 1
0
 /**
  * get carpet price, return carpets in same price range
  * @param  int $startPrice
  * @param  int $endPrice
  * @return json
  */
 public function getPrice($startPrice, $endPrice = '')
 {
     // fix price range
     $endPrice == '' ? $endPrice = $startPrice : '';
     $collection = collect();
     foreach (Price::whereBetween('price', [$startPrice, $endPrice])->get() as $price) {
         $collection[] = $price->carpet;
     }
     return self::makeJson($collection);
 }