public function run()
 {
     $profiles = ['Residential' => ['coverage' => 36], 'PBR' => ['coverage' => 36], 'Secure-Seam Standing Seam' => ['coverage' => 18], 'Perma-Lok Standing Seam' => ['coverage' => 16], '5-V' => ['coverage' => 24], 'Corrugated' => ['coverage' => 24], 'MECH-SEAM' => ['coverage' => 16]];
     $dirname = dirname(__FILE__);
     foreach ($profiles as $profileName => $profileInfo) {
         if (MetalProfile::where('name', '=', $profileName)->first()) {
             continue;
         }
         /*
         // Upload profile image
         copy( $dirname . "/default_images/colors/" . $colorInfo['image'], $dirname . "/" . $colorInfo['image'] );
         $file = new UploadedFile(
         	$dirname . "/" . $colorInfo['image'],             // path
         	$colorInfo['image'],                              // originalName
         	"image/png",                                      // mimeType
         	filesize( $dirname . "/" . $colorInfo['image'] ), // size
         	null,                                             // error
         	true                                              // test
         );
         $profileImage = ImageList::upload( $file );
         
         // Upload overhead image
         copy( $dirname . "/default_images/colors/" . $colorInfo['image'], $dirname . "/" . $colorInfo['image'] );
         $file = new UploadedFile(
         	$dirname . "/" . $colorInfo['image'],             // path
         	$colorInfo['image'],                              // originalName
         	"image/png",                                      // mimeType
         	filesize( $dirname . "/" . $colorInfo['image'] ), // size
         	null,                                             // error
         	true                                              // test
         );
         $overheadImage = ImageList::upload( $file );
         */
         $profile = MetalProfile::firstOrCreate(['name' => $profileName, 'coverage' => $profileInfo['coverage']]);
         $profile->save();
         foreach (Location::all() as $location) {
             foreach (Gauge::all() as $gauge) {
                 $locationProfileGauge = new LocationProfileGauge();
                 $locationProfileGauge->location()->associate($location);
                 $locationProfileGauge->metalProfile()->associate($profile);
                 $locationProfileGauge->gauge()->associate($gauge);
                 $locationProfileGauge->save();
             }
         }
     }
 }
 public function detach()
 {
     $location = Location::find(Request::input('location'));
     $profile = MetalProfile::find(Request::input('profile'));
     foreach (Gauge::all() as $gauge) {
         $locationProfileGauge = LocationProfileGauge::where('location_id', '=', $location->id)->where('metal_profile_id', '=', $profile->id)->where('gauge_id', '=', $gauge->id);
         if ($locationProfileGauge->first()) {
             $locationProfileGauge->first()->delete();
         }
     }
     return "success";
 }