public function join_contest() { $curdate = Carbon::now(); $timezone = Input::get('timezone'); $inputdetails = Input::except(array('_token', 'uploadfile', 'submitphoto', 'uploadtopic', 'timezone', 'topicvideo', 'topicphoto')); $inputdetails['uploaddate'] = $curdate; if (Input::file('uploadfile') != '') { $destinationPath = 'public/assets/upload/contest_participant_photo'; $filename = Input::file('uploadfile')->getClientOriginalName(); $Image = str_random(8) . '_' . $filename; $inputdetails['uploadfile'] = $Image; $validation = Validator::make($inputdetails, contestparticipantModel::$rules); } if (Input::get('uploadtopic') != '') { ////////New requirements///////////////// if (Input::file('topicphoto') != '') { $destinationtopicphoto = 'public/assets/upload/topicphotovideo'; $topicphoto = Input::file('topicphoto')->getClientOriginalName(); $topicImage = str_random(8) . '_' . $topicphoto; $inputdetails['topicphoto'] = $topicImage; } if (Input::file('topicvideo') != '') { $destinationtopicvideo = 'public/assets/upload/topicphotovideo'; $topicvideo = Input::file('topicvideo')->getClientOriginalName(); $topicvideoname = str_random(8) . '_' . $topicvideo; $inputdetails['topicvideo'] = $topicvideoname; } $inputdetails['uploadtopic'] = Input::get('uploadtopic'); //return $inputdetails; $validation = Validator::make($inputdetails, contestparticipantModel::$topicrules); } //return $validation->messages(); $user_id = Input::get('user_id'); $contest_id = Input::get('contest_id'); $verifyid = contestparticipantModel::where('contest_id', $contest_id)->where('user_id', $user_id)->get()->count(); $contestcount = contestModel::select('noofparticipant')->where('ID', $contest_id)->get(); $participantcount = contestparticipantModel::where('contest_id', $contest_id)->get()->count(); if ($verifyid) { if ($validation->passes()) { if (Input::file('uploadfile') != '') { $file = Input::file('uploadfile'); $uploadSuccess = $file->move($destinationPath, $Image); /// Dropbox ////////////// /*$appInfo = \Dropbox\AppInfo::loadFromJsonFile("app_info.json"); $webAuth = new \Dropbox\WebAuthNoRedirect($appInfo, "PHP-Example/1.0"); $authorizeUrl = $webAuth->start(); $accessToken = "LUu8h-uvauAAAAAAAAAAHbDw-bulVL7u8BoRAJtedc0-eCDY-Xj4Qxf1iGucUN7j"; $dbxClient = new \Dropbox\Client($accessToken, "PHP-Example/1.0"); $accountInfo = $dbxClient->getAccountInfo(); //file_get_contents($file->getRealPath()); $f = fopen($file->getRealPath(), "rb"); $result = $dbxClient->uploadFile("/participant/".$Image, \Dropbox\WriteMode::add(), $f); fclose($f); $inputdetails['dropbox_path']=$this->fetchUrl('/participant/'.$inputdetails['uploadfile']); */ /// Dropbox end //////// } if (Input::get('uploadtopic') != '') { if (Input::file('topicphoto') != '') { $topicphotofile = Input::file('topicphoto'); $uploadSuccess = $topicphotofile->move($destinationtopicphoto, $topicImage); } if (Input::file('topicvideo') != '') { $topicphotofile = Input::file('topicvideo'); $uploadSuccess = $topicphotofile->move($destinationtopicvideo, $topicvideoname); } } $participant = contestparticipantModel::where('contest_id', $contest_id)->where('user_id', $user_id)->update($inputdetails); return Redirect::to("contest_info/" . $contest_id)->with('tab', 'gallery'); } else { return Redirect::to("contest_info/" . $contest_id)->with('tab', 'join')->with('Massage', $validation->messages()->first()); } } else { if ($contestcount[0]['noofparticipant'] == $participantcount && $contestcount[0]['noofparticipant'] != 0) { return Redirect::to("contest_info/" . $contest_id)->with('tab', 'join')->with('Massage', 'Participants Limit Exceeded'); } else { if ($validation->passes()) { if (Input::file('uploadfile') != '') { $file = Input::file('uploadfile'); $uploadSuccess = $file->move($destinationPath, $Image); /// Dropbox ////////////// /* $appInfo = \Dropbox\AppInfo::loadFromJsonFile("app_info.json"); $webAuth = new \Dropbox\WebAuthNoRedirect($appInfo, "PHP-Example/1.0"); $authorizeUrl = $webAuth->start(); $accessToken = "LUu8h-uvauAAAAAAAAAAHbDw-bulVL7u8BoRAJtedc0-eCDY-Xj4Qxf1iGucUN7j"; $dbxClient = new \Dropbox\Client($accessToken, "PHP-Example/1.0"); $accountInfo = $dbxClient->getAccountInfo(); //file_get_contents($file->getRealPath()); $f = fopen($file->getRealPath(), "rb"); $result = $dbxClient->uploadFile("/participant/".$Image, \Dropbox\WriteMode::add(), $f); fclose($f); $inputdetails['dropbox_path']=$this->fetchUrl('/participant/'.$Image); */ /// Dropbox end //////// } if (Input::get('uploadtopic') != '') { if (Input::file('topicphoto') != '') { $topicphotofile = Input::file('topicphoto'); $uploadSuccess = $topicphotofile->move($destinationtopicphoto, $topicImage); } if (Input::file('topicvideo') != '') { $topicphotofile = Input::file('topicvideo'); $uploadSuccess = $topicphotofile->move($destinationtopicvideo, $topicvideoname); } } $participant = contestparticipantModel::create($inputdetails); return Redirect::to("contest_info/" . $contest_id)->with('tab', 'gallery'); } else { return Redirect::to("contest_info/" . $contest_id)->with('tab', 'join')->with('Massage', $validation->messages()->first()); } } } }
public function joincontest() { $curdate = Carbon::now(); $timezone = Input::get('timezone'); $inputdetails = Input::except(array('_token', 'uploadfile', 'uploadtopic', 'timezone')); $inputdetails['uploaddate'] = $curdate; if (Input::file('uploadfile') != '') { $destinationPath = 'public/assets/upload/contest_participant_photo'; $filename = Input::file('uploadfile')->getClientOriginalName(); $Image = str_random(8) . '_' . $filename; $inputdetails['uploadfile'] = $Image; $validation = Validator::make($inputdetails, contestparticipantModel::$rules); } if (Input::get('uploadtopic') != '') { $inputdetails['uploadtopic'] = Input::get('uploadtopic'); //return $inputdetails; $validation = Validator::make($inputdetails, contestparticipantModel::$topicrules); } ///// Check Already Participated user in this Contest or not $user_id = Input::get('user_id'); $contest_id = Input::get('contest_id'); $verifyid = contestparticipantModel::where('contest_id', $contest_id)->where('user_id', $user_id)->get()->count(); ///// Check the Participant count of the contest //////////// $contestcount = contestModel::select('noofparticipant')->where('ID', $contest_id)->get(); $participantcount = contestparticipantModel::where('contest_id', $contest_id)->get()->count(); if ($verifyid) { if ($validation->passes()) { if (Input::file('uploadfile') != '') { $file = Input::file('uploadfile'); $uploadSuccess = $file->move($destinationPath, $Image); /// Dropbox ////////////// /*$appInfo = \Dropbox\AppInfo::loadFromJsonFile("app_info.json"); $webAuth = new \Dropbox\WebAuthNoRedirect($appInfo, "PHP-Example/1.0"); $authorizeUrl = $webAuth->start(); $accessToken = "LUu8h-uvauAAAAAAAAAAHbDw-bulVL7u8BoRAJtedc0-eCDY-Xj4Qxf1iGucUN7j"; $dbxClient = new \Dropbox\Client($accessToken, "PHP-Example/1.0"); $accountInfo = $dbxClient->getAccountInfo(); //file_get_contents($file->getRealPath()); $f = fopen($file->getRealPath(), "rb"); $result = $dbxClient->uploadFile("/participant/".$Image, \Dropbox\WriteMode::add(), $f); fclose($f); $inputdetails['dropbox_path']=$this->fetchUrl('/participant/'.$inputdetails['uploadfile']); */ /// Dropbox end //////// } $participant = contestparticipantModel::where('contest_id', $contest_id)->where('user_id', $user_id)->update($inputdetails); $Response = array('success' => '1', 'message' => 'Record updated Successfully', 'msgcode' => "c109"); $final = array("response" => $Response); return json_encode($final); } else { $Response = array('success' => '0', 'message' => 'Some Parameter missing', 'msgcode' => "c101"); $final = array("response" => $Response); return json_encode($final); } } else { if ($contestcount[0]['noofparticipant'] != 0 && $contestcount[0]['noofparticipant'] == $participantcount) { $Response = array('success' => '0', 'message' => 'Contest Participant Limit is crossed', 'msgcode' => "c121"); $final = array("response" => $Response); return json_encode($final); } else { if ($validation->passes()) { if (Input::file('uploadfile') != '') { $file = Input::file('uploadfile'); $uploadSuccess = $file->move($destinationPath, $Image); /// Dropbox ////////////// /*$appInfo = \Dropbox\AppInfo::loadFromJsonFile("app_info.json"); $webAuth = new \Dropbox\WebAuthNoRedirect($appInfo, "PHP-Example/1.0"); $authorizeUrl = $webAuth->start(); $accessToken = "LUu8h-uvauAAAAAAAAAAHbDw-bulVL7u8BoRAJtedc0-eCDY-Xj4Qxf1iGucUN7j"; $dbxClient = new \Dropbox\Client($accessToken, "PHP-Example/1.0"); $accountInfo = $dbxClient->getAccountInfo(); //file_get_contents($file->getRealPath()); $f = fopen($file->getRealPath(), "rb"); $result = $dbxClient->uploadFile("/participant/".$Image, \Dropbox\WriteMode::add(), $f); fclose($f); $inputdetails['dropbox_path']=$this->fetchUrl('/participant/'.$inputdetails['uploadfile']); */ /// Dropbox end //////// } $participant = contestparticipantModel::create($inputdetails); $Response = array('success' => '1', 'message' => 'Record Added Successfully', 'msgcode' => "c107"); $final = array("response" => $Response); return json_encode($final); } else { $Response = array('success' => '0', 'message' => 'Some Parameter missing', 'msgcode' => "c120"); $final = array("response" => $Response); return json_encode($final); } } } }
public function joincontest() { $curdate = Carbon::now(); $timezone = Input::get('timezone'); $inputdetails = Input::except(array('_token', 'uploadfile', 'uploadtopic', 'timezone')); $inputdetails['uploaddate'] = $curdate; if (Input::file('uploadfile') != '') { $destinationPath = 'public/assets/upload/contest_participant_photo'; $filename = Input::file('uploadfile')->getClientOriginalName(); $Image = str_random(8) . '_' . $filename; $inputdetails['uploadfile'] = $Image; $validation = Validator::make($inputdetails, contestparticipantModel::$rules); } if (Input::get('uploadtopic') != '') { $inputdetails['uploadtopic'] = Input::get('uploadtopic'); //return $inputdetails; $validation = Validator::make($inputdetails, contestparticipantModel::$topicrules); } ///// Check Already Participated user in this Contest or not $user_id = Input::get('user_id'); $contest_id = Input::get('contest_id'); $verifyid = contestparticipantModel::where('contest_id', $contest_id)->where('user_id', $user_id)->get()->count(); ///// Check the Participant count of the contest //////////// $contestcount = contestModel::select('noofparticipant')->where('ID', $contest_id)->get(); $participantcount = contestparticipantModel::where('contest_id', $contest_id)->get()->count(); if ($verifyid) { if ($validation->passes()) { if (Input::file('uploadfile') != '') { $file = Input::file('uploadfile'); $uploadSuccess = $file->move($destinationPath, $Image); } $participant = contestparticipantModel::where('contest_id', $contest_id)->where('user_id', $user_id)->update($inputdetails); $Response = array('success' => '1', 'message' => 'Record updated Successfully'); $final = array("response" => $Response); return json_encode($final); } else { $Response = array('success' => '0', 'message' => 'Some Parameter missing'); $final = array("response" => $Response); return json_encode($final); } } else { if ($contestcount[0]['noofparticipant'] != 0 && $contestcount[0]['noofparticipant'] == $participantcount) { $Response = array('success' => '0', 'message' => 'Contest Participant Limit is crossed'); $final = array("response" => $Response); return json_encode($final); } else { if ($validation->passes()) { if (Input::file('uploadfile') != '') { $file = Input::file('uploadfile'); $uploadSuccess = $file->move($destinationPath, $Image); } $participant = contestparticipantModel::create($inputdetails); $Response = array('success' => '1', 'message' => 'Record Added Successfully'); $final = array("response" => $Response); return json_encode($final); } else { $Response = array('success' => '0', 'message' => 'Some Parameter missing'); $final = array("response" => $Response); return json_encode($final); } } } }