/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(StoreLanguageRequest $request, $id) { Language::find($id)->update($request->all()); // flash message session()->flash('flash_message', 'Language updated successfully.'); return redirect()->route('languages.index'); }
/** * Change language * @param $id * @return Response view */ public function change($id) { $language = Language::find($id); Language::where('is_default', '=', 1)->update(['is_default' => 0]); $language->is_default = 1; $language->save(); return redirect()->route('languages.index'); }
public function delete() { $main_folder = base_path() . '/resources/lang/'; $data = Request::input('data'); foreach ($data as $key => $value) { $item = Language::find($value); $code = $item->code; $files = glob($main_folder . $code . '/*'); foreach ($files as $file) { unlink($file); } rmdir($main_folder . $code); } Language::destroy($data); }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update($id) { $language = \App\Language::find($id); if ($language) { $rules = \App\Language::$rules; //$rules['name'] = 'required|min:2'; $validator = \Validator::make(\Input::all(), $rules); if ($validator->passes()) { $language = \App\Language::find($id); $language->name = \Input::get('name'); $language->save(); flash('Language updated.'); return \Redirect::back(); } return \Redirect::back()->withInput()->withErrors($validator); } flash()->error('Language does not exist.'); return \Redirect::back(); }
public function delete($id) { // Checking if language exists $language = Language::find($id); // If language exists if (!empty($language)) { // Finding related books $books = $this->booksService->getAllWithLanguage($id); if (!empty($books['data'])) { // Delete related books foreach ($books['data'] as $book) { $this->booksService->delete($book->id); } } // Delete language $language->delete(); // Returning success message return $this->responseService->returnSuccess(); } else { // Language not found // Returning error message return $this->responseService->errorMessage('Language was not Found.'); } }
/** * Store a newly created resource in storage. * * @return Response */ public function store(Request $request) { $input = $request->input(); if ($input['level'] == 1) { /*$photo = array('resume_photo' => Input::file('resume_photo'),'passport' =>Input::file('passport')); $rules = array('resume_photo' => 'required');//mimes:jpeg,bmp,png|max:10000','passport' => 'required|mimes:jpeg,png,pdf,doc|max:10000'); //mimes:jpeg,bmp,png and for max size max:10000 // doing the validation, passing post data, rules and the messages $validator = Validator::make($photo, $rules); if ($validator->fails()) { // send back to the page with the input data and errors return Redirect::to('resume.create')->withInput()->withErrors($validator); } else {*/ if (Input::file('resume_photo')) { $resume_photo = array('file' => Input::file('resume_photo'), 'extention' => Input::file('resume_photo')->getClientOriginalExtension()); $rules = array('file' => 'required|max:2048', 'extention' => 'required|In:jpeg,bmp,png'); $validator = Validator::make($resume_photo, $rules); if ($validator->fails()) { // send back to the page with the input data and errors // $validator->errors()->add('resume_photo', 'Invalide File'); Session::flash('message', 'File must be less than 2Mb and only jpeg,bmp,png'); return view('resume.create')->withErrors($validator)->with('id', $input['resumeId'])->with('state', $input['level']); } else { $destinationPath = 'upload'; $photoExtension = Input::file('resume_photo')->getClientOriginalExtension(); $photoName = rand(11111, 99999) . '_photo' . '.' . $photoExtension; Input::file('resume_photo')->move($destinationPath, $photoName); } } if (Input::file('passport')) { $passport = array('file' => Input::file('passport'), 'extention' => Input::file('passport')->getClientOriginalExtension()); $rules = array('file' => 'required|max:2048', 'extention' => 'required|In:jpeg,bmp,png,pdf,doc,docx'); $validator = Validator::make($passport, $rules); if ($validator->fails()) { // send back to the page with the input data and errors // $validator->errors()->add('passport', 'File size must be less than 2MB and only .jpeg,.bmp,.png'); Session::flash('message', 'File must be less than 2Mb and only jpeg,bmp,png,pdf,doc,docx'); return view('resume.create')->withErrors($validator)->with('id', $input['resumeId'])->with('state', $input['level']); } else { $destinationPath = 'upload'; $passportExtension = Input::file('passport')->getClientOriginalExtension(); $passportName = rand(11111, 99999) . '_passport' . '.' . $passportExtension; Input::file('passport')->move($destinationPath, $passportName); } } $ret = PersonalInformation::where('id', $input['resumeId'])->first(); if ($ret) { $resume = PersonalInformation::find($input['resumeId']); $resume->fname = $input['fname']; $resume->lname = $input['lname']; $resume->resume_photo = isset($photoName) ? $photoName : $ret->resume_photo; $resume->passport = isset($passportName) ? $passportName : $ret->passport; $resume->dob = $input['dob']; $resume->age = $input['age']; $resume->gender = $input['gender']; $resume->height = $input['height']; $resume->email = $input['email']; $resume->nationality = $input['nationality']; $resume->mobile = $input['mobile']; $resume->onumber = isset($input['onumber']) ? $input['onumber'] : ''; $resume->raddress1 = $input['raddress1']; $resume->raddress2 = $input['raddress2']; $resume->city = isset($input['city']) ? $input['city'] : ''; $resume->postal_code = $input['postal_code']; $resume->country = $input['country']; $resume->state = $input['state']; $resume->identification = $input['identification']; $resume->inumber = $input['inumber']; $resume->save(); $rethistory = History::whereAction_idAndAction($resume->id, 'Resume Updated')->first(); if ($rethistory) { $history = History::find($rethistory->id); $history->action = 'Resume Updated'; $history->user = Auth::user()->name; $history->remark = ''; $history->save(); } else { $history = new History(); $history->action_id = $resume->id; $history->action = 'Resume Updated'; $history->user = Auth::user()->name; $history->remark = ''; $history->save(); } } else { $resume = new PersonalInformation(); $resume->agent_id = Auth::user()->id; $resume->approval_status = 0; $resume->approved_by = 0; $resume->agent_approval_delete = 0; $resume->fname = $input['fname']; $resume->lname = $input['lname']; $resume->resume_photo = isset($photoName) ? $photoName : ''; $resume->passport = isset($passportName) ? $passportName : ''; $resume->dob = $input['dob']; $resume->age = $input['age']; $resume->gender = $input['gender']; $resume->height = $input['height']; $resume->email = $input['email']; $resume->nationality = $input['nationality']; $resume->mobile = $input['mobile']; $resume->onumber = isset($input['onumber']) ? $input['onumber'] : ''; $resume->raddress1 = $input['raddress1']; $resume->raddress2 = $input['raddress2']; $resume->city = isset($input['city']) ? $input['city'] : ''; $resume->postal_code = $input['postal_code']; $resume->country = $input['country']; $resume->state = $input['state']; $resume->identification = $input['identification']; $resume->inumber = $input['inumber']; $resume->save(); $history = new History(); $history->action_id = $resume->id; $history->action = 'Resume Created'; $history->user = Auth::user()->name; $history->remark = ''; $history->save(); } return view('resume.create')->with('id', $resume->id)->with('state', $input['level'] + 1); //} } if ($input['level'] == 2 && $input['resumeId'] > 0) { $eduChecked = Input::get('edu'); if ($eduChecked) { $edudel = EducationalInformation::where('pid', $input['resumeId'])->whereNotIn('degree', $eduChecked)->delete(); foreach ($eduChecked as $educationChecked) { if ($educationChecked == 'phd') { $prefe = 1; } else { if ($educationChecked == 'master') { $prefe = 2; } else { if ($educationChecked == 'bachelor') { $prefe = 3; } else { if ($educationChecked == 'intermediate') { $prefe = 4; } else { if ($educationChecked == 'slc') { $prefe = 5; } else { $prefe = 6; } } } } } $ret = EducationalInformation::wherePidAndDegree($input['resumeId'], $educationChecked)->first(); if ($ret) { $resume = EducationalInformation::find($ret['id']); $resume->pid = $input['resumeId']; $resume->degree = $educationChecked; $resume->preference = $prefe; $resume->major = $input['major_' . $educationChecked]; $resume->gyear = $input['gradyear_' . $educationChecked]; $resume->school = $input['school_' . $educationChecked]; $resume->board = $input['board_' . $educationChecked]; $resume->grade = $input['percentage_' . $educationChecked]; $resume->resume_certificate = ''; $resume->save(); } else { $resume = new EducationalInformation(); $resume->pid = $input['resumeId']; $resume->degree = $educationChecked; $resume->preference = $prefe; $resume->major = $input['major_' . $educationChecked]; $resume->gyear = $input['gradyear_' . $educationChecked]; $resume->school = $input['school_' . $educationChecked]; $resume->board = $input['board_' . $educationChecked]; $resume->grade = $input['percentage_' . $educationChecked]; $resume->resume_certificate = ''; $resume->save(); } } } return view('resume.create')->with('id', $input['resumeId'])->with('state', $input['level'] + 1); //$resume-> //} } if ($input['level'] == 3 && $input['resumeId'] > 0) { if (Input::file('exp_certificate')) { $exp_certificate = array('file' => Input::file('exp_certificate'), 'extention' => Input::file('exp_certificate')->getClientOriginalExtension()); $rules = array('file' => 'required|max:2048', 'extention' => 'required|In:jpeg,bmp,png,pdf,doc,docx'); $validator = Validator::make($exp_certificate, $rules); if ($validator->fails()) { // send back to the page with the input data and errors // $validator->errors()->add('passport', 'File size must be less than 2MB and only .jpeg,.bmp,.png'); Session::flash('message', 'File must be less than 2Mb and only jpeg,bmp,png,pdf,doc,docx'); return view('resume.create')->withErrors($validator)->with('id', $input['resumeId'])->with('state', $input['level']); } else { $exp_certificate = array('exp_certificate' => Input::file('exp_certificate')); $destinationPath = 'upload'; $expCertificateExtension = Input::file('exp_certificate')->getClientOriginalExtension(); $expCertificateName = rand(11111, 99999) . '_expcertificate' . '.' . $expCertificateExtension; Input::file('exp_certificate')->move($destinationPath, $expCertificateName); } } $ret = WorkInformation::where('pid', $input['resumeId'])->first(); if ($ret) { $resume = WorkInformation::where('pid', $input['resumeId'])->update(['pid' => $input['resumeId'], 'position_title' => $input['position_title'], 'company_name' => $input['company_name'], 'from_date' => $input['from_date'], 'to_date' => isset($input['wpresent']) ? 1 : $input['to_date'], 'experience' => $input['experience'], 'specialization' => $input['specialization'], 'role' => $input['role'], 'country' => $input['country'], 'industry' => isset($input['industry']) ? $input['industry'] : $ret->industry, 'position_level' => isset($input['position_level']) ? $input['position_level'] : $ret->position_level, 'currency' => isset($input['currency']) ? $input['currency'] : $ret->currency, 'salary' => $input['salary'], 'experience_certificate' => isset($expCertificateName) ? $expCertificateName : $ret->experience_certificate]); } else { $resume = new WorkInformation(); $resume->pid = $input['resumeId']; $resume->position_title = $input['position_title']; $resume->company_name = $input['company_name']; $resume->experience = $input['experience']; $resume->from_date = $input['from_date']; $resume->to_date = isset($input['wpresent']) ? 1 : $input['to_date']; $resume->specialization = $input['specialization']; $resume->role = $input['role']; $resume->country = $input['country']; $resume->industry = isset($input['industry']) ? $input['industry'] : ''; $resume->position_level = isset($input['position_level']) ? $input['position_level'] : ''; $resume->currency = isset($input['currency']) ? $input['currency'] : ''; $resume->salary = $input['salary']; $resume->experience_certificate = isset($expCertificateName) ? $expCertificateName : ''; $resume->save(); } return view('resume.create')->with('id', $input['resumeId'])->with('state', $input['level'] + 1); //$resume-> } if ($input['level'] == 4 && $input['resumeId'] > 0) { $t = $input['skillCount']; for ($c = 1; $c <= $t; $c++) { if (Input::file('skills_certificate_' . $c)) { $skills_certificate = array('file' => Input::file('skills_certificate_' . $c), 'extention' => Input::file('skills_certificate_' . $c)->getClientOriginalExtension()); $rules = array('file' => 'required|max:2048', 'extention' => 'required|In:jpeg,bmp,png,pdf,doc,docx'); $validator = Validator::make($skills_certificate, $rules); if ($validator->fails()) { // send back to the page with the input data and errors // $validator->errors()->add('passport', 'File size must be less than 2MB and only .jpeg,.bmp,.png'); Session::flash('message', 'File must be less than 2Mb and only jpeg,bmp,png,pdf,doc,docx'); return view('resume.create')->withErrors($validator)->with('id', $input['resumeId'])->with('state', $input['level']); } else { $skill_certificate = array('skills_certificate_' . $c => Input::file('skills_certificate_' . $c)); $destinationPath = 'upload'; $skillCertificateExtension = Input::file('skills_certificate_' . $c)->getClientOriginalExtension(); $skillCertificateName = rand(11111, 99999) . '_skill_certificate' . '.' . $skillCertificateExtension; Input::file('skills_certificate_' . $c)->move($destinationPath, $skillCertificateName); } } else { $skillCertificateName = ''; } $ret = SkillsInformation::wherePidAndSkills($input['resumeId'], $input["skill_" . $c])->first(); if ($ret) { $resume = SkillsInformation::find($ret->id); // $resume->skills = $input["skill_".$c]; $resume->proficiency = $input["proficiency_" . $c]; if ($skillCertificateName != '') { $resume->skills_certificate = $skillCertificateName; } $resume->save(); } else { $resume = new SkillsInformation(); $resume->pid = $input['resumeId']; $resume->skills = $input["skill_" . $c]; $resume->proficiency = $input["proficiency_" . $c]; $resume->skills_certificate = isset($skillCertificateName) ? $skillCertificateName : ''; $resume->save(); } } return view('resume.create')->with('id', $input['resumeId'])->with('state', $input['level'] + 1); //$resume-> } if ($input['level'] == 5 && $input['resumeId'] > 0) { //return $input; $t = $input['languageCount']; for ($c = 1; $c <= $t; $c++) { $ret = Language::wherePidAndLanguage($input['resumeId'], $input['language_' . $c])->first(); if ($ret) { $resume = Language::find($ret->id); $resume->lspoken = $input['lspoken_' . $c]; $resume->lwritten = $input['lwritten_' . $c]; $resume->save(); } else { $resume = new Language(); $resume->pid = $input['resumeId']; $resume->language = $input['language_' . $c]; $resume->lspoken = $input['lspoken_' . $c]; $resume->lwritten = $input['lwritten_' . $c]; $resume->save(); } } return view('resume.create')->with('id', $input['resumeId'])->with('state', $input['level'] + 1); //$resume-> } if ($input['level'] == 6 && $input['resumeId'] > 0) { if (Input::file('sdocument')) { $sdocument = array('file' => Input::file('sdocument'), 'extention' => Input::file('sdocument')->getClientOriginalExtension()); $rules = array('file' => 'required|max:2048', 'extention' => 'required|In:jpeg,bmp,png,pdf,doc,docx'); $validator = Validator::make($sdocument, $rules); if ($validator->fails()) { // send back to the page with the input data and errors // $validator->errors()->add('passport', 'File size must be less than 2MB and only .jpeg,.bmp,.png'); Session::flash('message', 'File must be less than 2Mb and only jpeg,bmp,png,pdf,doc,docx'); return view('resume.create')->withErrors($validator)->with('id', $input['resumeId'])->with('state', $input['level']); } else { $sdocument = array('sdocument' => Input::file('sdocument')); $destinationPath = 'upload'; $sdocumentExtension = Input::file('sdocument')->getClientOriginalExtension(); $sdocumentName = rand(11111, 99999) . '_sdocument' . '.' . $sdocumentExtension; Input::file('sdocument')->move($destinationPath, $sdocumentName); } } $ret = AdditionalInformation::where('pid', $input['resumeId'])->first(); if ($ret) { $resume = AdditionalInformation::find($ret->id); $resume->sdocument = isset($sdocumentName) ? $sdocumentName : $ret->sdocument; } else { $resume = new AdditionalInformation(); $resume->sdocument = isset($sdocumentName) ? $sdocumentName : ''; } $resume->pid = $input['resumeId']; $resume->currency = $input['currency']; $resume->salary = $input['salary']; $resume->preferred_location = $input['prefered_location']; $resume->add_information = $input['add_information']; $resume->save(); return view('resume.create')->with('id', $input['resumeId'])->with('state', $input['level'] + 1); //$resume-> } if ($input['level'] == 7 && $input['resumeId'] > 0) { if (Input::file('uresume')) { $uresume = array('file' => Input::file('uresume'), 'extention' => Input::file('uresume')->getClientOriginalExtension()); $rules = array('file' => 'required|max:2048', 'extention' => 'required|In:pdf,doc,docx'); $validator = Validator::make($uresume, $rules); if ($validator->fails()) { // send back to the page with the input data and errors $validator->errors()->add('uresume', 'File size must be less than 2MB and only .pdf,.doc,.docx'); return view('resume.create')->withErrors($validator)->with('id', $input['resumeId'])->with('state', $input['level']); } else { $uresume = array('uresume' => Input::file('uresume')); $destinationPath = 'upload'; $uresumeExtension = Input::file('uresume')->getClientOriginalExtension(); $uresumeName = rand(11111, 99999) . '_CV' . '.' . $uresumeExtension; Input::file('uresume')->move($destinationPath, $uresumeName); } } $ret = UploadInformation::where('pid', $input['resumeId'])->first(); if ($ret) { $resume = UploadInformation::find($ret->id); $resume->uresume = isset($uresumeName) ? $uresumeName : $ret->uresume; } else { $resume = new UploadInformation(); $resume->uresume = isset($uresumeName) ? $uresumeName : ''; } $resume->pid = $input['resumeId']; $resume->save(); return view('resume.create')->with('id', $input['resumeId'])->with('state', $input['level'] + 1); //$resume-> } if ($input['level'] == 8 && $input['resumeId'] > 0) { $ret = PrivacyInformation::where('pid', $input['resumeId'])->first(); if ($ret) { $resume = PrivacyInformation::find($ret->id); } else { $resume = new PrivacyInformation(); } $resume->pid = $input['resumeId']; $resume->privacy = $input['privacy']; $resume->save(); Session::flash('message', 'Resume has been created Successfully'); return Redirect::to('resume'); // return view('resume.create')->with('id',$input['resumeId'])->with('state',($input['level'] + 1)); //$resume-> } // if($input['level'] == 9) { // return Redirect::to('resume'); // } Session::flash('message', 'Please Fill up Personal Information First!!'); return view('resume.create')->with('id', 0)->with('state', 1); }
/** * Remove the specified resource from storage. * * @param $id * @return Response */ public function postDelete(DeleteRequest $request, $id) { $language = Language::find($id); $language->delete(); }
/** * Run the database seeds. */ public function run() { $country = Country::find(1); $language = Language::find(1); User::create(['id' => 1, 'name' => 'John', 'surname' => 'Doe', 'username' => 'Doe', 'password' => base64_encode('123'), 'email' => '*****@*****.**', 'direction' => 'going up', 'enabled' => true, 'country_id' => $country->id, 'language_id' => $language->id]); }
/** * Delete a language from the users profile. */ public function deleteLanguage($languege_id, Request $request) { $l = Language::find($languege_id); $correct = false; if ($l) { $correct = $l->delete(); $message = $correct ? 'Language deleted successfully' : "Language couldn't be deleted"; } if ($request->ajax()) { return \Response::json(array('correct' => $correct, 'message' => $message)); } \Session::flash('message', 'Language deleted successfully'); return redirect()->route('profile.edit'); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { /* |-------------------------------------------------------------------------- | Application Configuration |-------------------------------------------------------------------------- | | Load Configuration Keys. | */ Configuration::loadConfiguration(); if (Auth::check()) { $user = User::with('language')->find(Auth::id()); // $email = Auth::user()->email; $language = $user->language; } else { $user = NULL; $language = Language::find(intval(Request::cookie('user_language'))); if (!$language) { $language = Language::findOrFail(intval(Configuration::get('DEF_LANGUAGE'))); } } $company = Company::with('currency')->findOrFail(intval(Configuration::get('DEF_COMPANY'))); Context::getContext()->user = $user; Context::getContext()->language = $language; Context::getContext()->company = $company; Context::getContext()->currency = $company->currency; Context::getContext()->controller = $request->segment(1); if ($request->segment(3) == 'attributes') { Context::getContext()->controller = $request->segment(3); } Context::getContext()->action = NULL; //$action; /* * / // echo_r($request->route()->getAction()); // http://laravel.io/forum/10-15-2014-laravel-5-passing-parameters-to-middleware-handlers // http://www.codeheaps.com/php-programming/laravel-5-middleware-stack-decoded/ // http://blog.elliothesp.co.uk/coding/passing-parameters-middleware-laravel-5/ // https://gist.github.com/dwightwatson/6200599 // http://stackoverflow.com/questions/26840278/laravel-5-how-to-get-route-action-name $action = $request->route()->getAction(); $routeArray = Str::parseCallback($action['controller'], null); if (last($routeArray) != null) { // Remove 'controller' from the controller name. $controller = str_replace('Controller', '', class_basename(head($routeArray))); // Take out the method from the action. $action = str_replace(['get', 'post', 'patch', 'put', 'delete'], '', last($routeArray)); // return Str::slug($controller . '-' . $action); } else { // return 'closure'; $controller = 'closure'; $action = ''; } // gist ENDS Context::getContext()->controller = $controller; Context::getContext()->action = $action; echo Str::slug($controller . '-' . $action); / * */ // Changing Timezone At Runtime. But this change does not seem to be taken by Carbon... Why? Config::set('app.timezone', Configuration::get('TIMEZONE')); // Changing The Default Language At Runtime App::setLocale(Context::getContext()->language->iso_code); return $next($request); }
public function delete(Request $request) { if (!ACL::hasPermission('languages', 'delete')) { return redirect(route('languages'))->withErrors(['You don\'t have permission for delete the languages.']); } //DELETE CURRENT FLAG if ($request->flag != "") { if (File::exists($this->folder . $request->flag)) { File::delete($this->folder . $request->flag); } } Language::find($request->get('languageId'))->delete(); $success = "Language deleted successfully."; return redirect(route('languages'))->with(compact('success')); }
/** * Run the database seeds. */ public function run() { $user = User::find(1); $language = Language::find(1); Task::create(['id' => 1, 'name' => 'First task', 'description' => 'My first new task', 'user_id' => $user->id, 'language_id' => $language->id]); }