public function xlsProductFile()
 {
     $namefile = date('Y:h:i:s') . "_Products";
     Excel::create($namefile, function ($excel) {
         // Set the title
         $excel->setTitle('NMK Group Of Companies');
         // Chain the setters
         $excel->setCreator('NMK Application')->setCompany('NMK');
         // Call them separately
         $excel->setDescription('This files has all products');
         $excel->sheet('Products', function ($sheet) {
             if ($_GET['val'] == "all") {
                 $products = Product::where('product_type', 'Product')->get();
             } else {
                 if ($_GET['val'] == "custom") {
                     $products = Product::where('product_type', 'Custom Cable')->get();
                 } else {
                     if ($_GET['val'] == "7") {
                         $dt = Carbon::now();
                         $products = Product::where('created_at', '>=', $dt->subDays(7))->get();
                     } else {
                         if ($_GET['val'] == "30") {
                             $dt = Carbon::now();
                             $products = Product::where('created_at', '>=', $dt->subDays(30))->get();
                         } else {
                             $products = Product::where('company', '002')->get();
                         }
                     }
                 }
             }
             $sheet->setStyle(array('font' => array('name' => 'Calibri', 'size' => 13)));
             $sheet->row(1, array('Company', 'Person name', 'Item code', 'Alternative code', 'Description', 'Measurement unit', 'Retail price', 'Brand', 'Main supplier', 'Family', 'Group', 'Category', 'Sub category', 'Country', 'Inside box quantity', 'Master pack weight', 'L cm', 'W cm', 'H cm', 'HS code'));
             foreach ($products as $key => $value) {
                 $sheet->row(1, function ($row) {
                     // call cell manipulation methods
                     $row->setBackground('#888888');
                     $row->setFont(array('family' => 'Calibri', 'size' => '16', 'bold' => true));
                 });
                 $sheet->setColumnFormat(array('C' => '0', 'D' => '0'));
                 $sheet->rows(array(array($value->company, $value->person_name, $value->item_code, $value->alternative_code, $value->description, $value->measurement_unit, $value->retail_price, $value->brand, $value->main_supplier, $value->family, $value->group, $value->category, $value->sub_category, $value->country, $value->inside_box_quantity, $value->master_pack_weight, $value->l_cm, $value->w_cm, $value->h_cm, $value->hs_code)));
             }
             //$sheet->fromModel($roles);
             // $sheet->fromArray(array(
             //     array('Name', 'Phone','Email','Job Title','Company','Intrested Brand','Intrested Seminiar'),
             //     $leads
             // ));
             $sheet->setOrientation('landscape');
         });
         // Our second sheet
         if ($_GET['val'] == "custom" || $_GET['val'] == "7" || $_GET['val'] == "30") {
             $excel->sheet('Custom Cable Recipe', function ($sheet) {
                 if ($_GET['val'] == "custom") {
                     $cable_products = Cable::all();
                 } else {
                     if ($_GET['val'] == "7") {
                         $dt = Carbon::now();
                         $cable_products = Cable::where('created_at', '>=', $dt->subDays(7))->get();
                     } else {
                         if ($_GET['val'] == "30") {
                             $dt = Carbon::now();
                             $cable_products = Cable::where('created_at', '>=', $dt->subDays(30))->get();
                         }
                     }
                 }
                 $sheet->setStyle(array('font' => array('name' => 'Calibri', 'size' => 13)));
                 $sheet->row(1, array('Item Code', 'Components', 'Description', 'Qty', 'Measurement Unit'));
                 foreach ($cable_products as $key => $value) {
                     $sheet->row(1, function ($row) {
                         // call cell manipulation methods
                         $row->setBackground('#888888');
                         $row->setFont(array('family' => 'Calibri', 'size' => '16', 'bold' => true));
                     });
                     $sheet->setColumnFormat(array('A' => '0'));
                     $sheet->rows(array(array($value->product_name, $value->recipe_components, $value->recipe_desc, $value->recipe_qty, $value->recipe_mu)));
                 }
                 $sheet->setOrientation('landscape');
             });
         }
     })->export('xls');
 }