/**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index($param = false)
 {
     $limit = 10;
     if ($param) {
         $condition_arr = array('is_deleted' => 0, 'discountinue' => 1);
         $products = Product::with('GetBrandDetails', 'AllProductFormfactors')->where($condition_arr)->where('product_name', 'LIKE', '%' . $param . '%')->orderBy('id', 'DESC')->paginate($limit);
         $products->setPath('product-list');
     } else {
         $condition_arr = array('is_deleted' => 0, 'discountinue' => 1);
         $products = Product::with('GetBrandDetails', 'AllProductFormfactors')->where($condition_arr)->orderBy('id', 'DESC')->paginate($limit);
         $products->setPath('product-list');
     }
     //Get all formfactor names
     if (!empty($products)) {
         foreach ($products as $key => $value) {
             if (!empty($value->AllProductFormfactors)) {
                 $value->formfactor_name = '';
                 $value->formfactor_price = '';
                 foreach ($value->AllProductFormfactors as $key1 => $each_formfactor) {
                     if ($each_formfactor['servings'] != 0) {
                         $frm_fctr = DB::table('form_factors')->where('id', $each_formfactor['formfactor_id'])->first();
                         // Assign Form-factor and its price
                         $value->formfactor_name .= ' ' . $frm_fctr->name . ' => $' . number_format($each_formfactor->actual_price, 2) . '<br/>';
                     }
                 }
             }
         }
     }
     //echo "<pre>";print_r($products);     exit;
     return view('admin.product.index', compact('products', 'param'), array('title' => 'Discontinue Products', 'module_head' => 'Discontinue Products'));
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index($discountinue = false, $param = false)
 {
     // $lib = new Usps();
     // $arr = array('user'=>'293TESTC3874','Zip5'=>'90210','FromName'=>'John Doe','FromAddress1'=>'RM 2100','FromAddress2'=>'475 L’Enfant Plaza SW','FromCity'=>'Washington','FromState'=>'DC','FromZip5'=>20260,'ToName'=>'Janice Dickens','ToFirm'=>'XYZ Corporation','ToAddress1'=>'Ste 100','ToAddress2'=>'2 Massachusetts Ave NE','ToCity'=>'Washington','ToState'=>'DC','ToZip5'=>20212,'WeightInOunces'=>10,'ServiceType'=>'PRIORITY','Size'=>'LARGE','Width'=>7,'Length'=>20.5,'Height'=>15,'Girth'=>60);
     // $lib->USPSLabel($arr);exit;
     $limit = 10;
     if ($param) {
         $condition_arr = array('is_deleted' => 0, 'discountinue' => $discountinue);
         $products = Product::with('GetBrandDetails', 'AllProductFormfactors')->where($condition_arr)->where('product_name', 'LIKE', '%' . $param . '%')->orderBy('id', 'DESC')->paginate($limit);
         $products->setPath('product-list/' . $discountinue . '/' . $param);
     } else {
         $condition_arr = array('is_deleted' => 0, 'discountinue' => $discountinue);
         $products = Product::with('GetBrandDetails', 'AllProductFormfactors')->where($condition_arr)->orderBy('id', 'DESC')->paginate($limit);
         //$products->setPath('product-list/'.$discountinue);
     }
     //Get all formfactor names
     if (!empty($products)) {
         foreach ($products as $key => $value) {
             if (!empty($value->AllProductFormfactors)) {
                 $value->formfactor_name = '';
                 $value->formfactor_price = '';
                 foreach ($value->AllProductFormfactors as $key1 => $each_formfactor) {
                     if ($each_formfactor['servings'] != 0) {
                         $frm_fctr = DB::table('form_factors')->where('id', $each_formfactor['formfactor_id'])->first();
                         // Assign Form-factor and its prices
                         $value->formfactor_name .= ' ' . $frm_fctr->name . ' ($' . number_format($each_formfactor->actual_price, 2) . ')<br/>';
                     }
                 }
             }
         }
     }
     if ($discountinue == 0) {
         $title = "Continue";
     } else {
         $title = "Discontinue";
     }
     //echo "<pre>";print_r($products);     exit;
     return view('admin.product.index', compact('products', 'param', 'discountinue'), array('title' => $title . ' Products', 'module_head' => $title . ' Products'));
 }