public function index()
 {
     if (Input::has("data")) {
         $errorFlag = 0;
         $data = Input::get('data');
         $file = Input::file('image');
         $floors = Input::file('floor');
         $floor_title = Input::get('floor_title');
         $threeSixty = Input::file('three_sixty');
         $statuses = Input::file('status');
         $status_title = Input::get('status_title');
         $validation = $validator = Validator::make(['Name' => $data['name'], 'Address' => $data['address'], 'Location' => $data['location'], 'Overview' => $data['overview'], 'Project_status' => $data['project_status'], 'Amenities' => $data['amenities'], 'Latitude' => $data['latitude'], 'Longitude' => $data['longitude']], ['Name' => 'required', 'Address' => 'required', 'Location' => 'required', 'Overview' => 'required', 'Project_status' => 'required', 'Amenities' => 'required', 'Latitude' => 'required', 'Longitude' => 'required', 'image' => 'mimes:jpeg,jpg,png']);
         $errors = $validation->errors();
         if ($file != '') {
             $size = $file->getSize();
             $error = $file->getError();
             $fileMaxActual = ini_get('upload_max_filesize');
             if (($size == '' || empty($size)) && $error == 1) {
                 $errorFlag = 1;
                 $errors->add('error1', 'Your file exceeds maximum upload size of ' . $fileMaxActual);
             }
         }
         if ($threeSixty != '') {
             $size2 = $threeSixty->getSize();
             $error2 = $threeSixty->getError();
             $fileMaxActual2 = ini_get('upload_max_filesize');
             if (($size2 == '' || empty($size2)) && $error2 == 1) {
                 $errorFlag2 = 1;
                 $errors->add('error3', 'Your 360 degree view file exceeds maximum upload size of ' . $fileMaxActual);
             }
         }
         foreach ($floors as $key => $floor) {
             if ($floor != '') {
                 $size1 = $floor->getSize();
                 $error1 = $floor->getError();
                 $fileMaxActual1 = ini_get('upload_max_filesize');
                 if ($floor_title[$key] == '') {
                     $errorFlag = 1;
                     $errors->add('error10', 'One of your Uploaded Floor Plan file doesnot have a title');
                 }
                 if (($size1 == '' || empty($size1)) && $error1 == 1) {
                     $errorFlag = 1;
                     $errors->add('error2', 'One of your floor plan file exceeds maximum upload size of ' . $fileMaxActual);
                 }
             }
         }
         foreach ($statuses as $key => $status) {
             if ($status != '') {
                 $size2 = $status->getSize();
                 $error2 = $status->getError();
                 $fileMaxActual2 = ini_get('upload_max_filesize');
                 if ($status_title[$key] == '') {
                     $errorFlag = 1;
                     $errors->add('error10', 'One of your Uploaded status files doesnot have a title');
                 }
                 if (($size2 == '' || empty($size2)) && $error2 == 1) {
                     $errorFlag = 1;
                     $errors->add('error2', 'One of your Status file exceeds maximum upload size of ' . $fileMaxActual);
                 }
             }
         }
         if ($validation->fails() || $errorFlag == 1) {
             return Redirect::to('admin/project')->withInput()->withErrors($errors);
         }
         if ($file != '') {
             $destinationPath = 'uploads/projects';
             $fileExtension = $file->getClientOriginalExtension();
             $fileName = date('YmdiHs') . rand(11111, 999999) . '.' . $fileExtension;
             $uploadSuccessTable = $file->move($destinationPath, $fileName);
             $data['image_location'] = $fileName;
         }
         if ($threeSixty != '') {
             $destinationPath = 'uploads/three-sixty';
             $fileExtension = $threeSixty->getClientOriginalExtension();
             $fileName = date('YmdiHs') . rand(11111, 999999) . '.' . $fileExtension;
             $uploadSuccessTable = $threeSixty->move($destinationPath, $fileName);
             $data['three_sixty_image'] = $fileName;
         }
         $floorCount = 0;
         $floorPlan = array();
         foreach ($floors as $key => $floor) {
             if ($floor != '') {
                 if ($floor_title[$key] != '') {
                     $destinationPath = 'uploads/project-floor-plan';
                     $fileExtension = $floor->getClientOriginalExtension();
                     $fileName = date('YmdiHs') . rand(11111, 999999) . '.' . $fileExtension;
                     $uploadSuccessTable = $floor->move($destinationPath, $fileName);
                     $floorPlan[$floorCount]['image'] = $fileName;
                     $floorPlan[$floorCount]['image_title'] = $floor_title[$key];
                     $floorCount++;
                 }
             }
         }
         $statusCount = 0;
         $statusArray = array();
         foreach ($statuses as $key => $status) {
             if ($status != '') {
                 if ($status_title[$key] != '') {
                     $destinationPath2 = 'uploads/project-status';
                     $fileExtension2 = $status->getClientOriginalExtension();
                     $fileName2 = date('YmdiHs') . rand(11111, 999999) . '.' . $fileExtension2;
                     $uploadSuccessTable = $status->move($destinationPath2, $fileName2);
                     $statusArray[$statusCount]['image'] = $fileName2;
                     $statusArray[$statusCount]['image_title'] = $status_title[$key];
                     $statusCount++;
                 }
             }
         }
         $projectsTable = new \App\Model\Projects();
         $project = $projectsTable->insertData($data, $floorPlan, $statusArray);
         if ($project) {
             $message['message'] = 'Successfully Saved';
             return Redirect::to('admin/project')->withErrors($message);
         } else {
             $message['message'] = 'Something went wrong';
             return Redirect::to('admin/project')->withErrors($message);
         }
     }
     $albumTable = new \App\Model\Album();
     //        $floorPlan = $albumTable->getAllAlbumsFloorPlanAsList();
     //        $projectStatus = $albumTable->getAllAlbumProjectStatusList();
     //        $data['floorPlan'] = $floorPlan;
     //        $data['projectStatus'] = $projectStatus;
     return View('/admin/projects');
 }