/**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     $input = $request->input();
     $data = $request->only('old_password', 'password', 'password_confirm');
     $rules = array('old_password' => 'required', 'password' => 'required', 'password_confirm' => 'required');
     $v = \Validator::make($data, $rules);
     if ($v->fails()) {
         return view('member.password_create')->withErrors($v)->withInput($data);
     } else {
         $old_password = $input['old_password'];
         //$old_password = Hash::make($old_password);
         if (Hash::check($old_password, Auth::user()->password)) {
             $password = $input['password'];
             $password = \Hash::make($password);
             $update = DB::table('members')->where('id', Auth::user()->id)->update(['password' => $password]);
             $history = new History();
             $history->action_id = Auth::user()->id;
             $history->action = 'Password Changed';
             $history->user = Auth::user()->name;
             $history->remark = '';
             $history->save();
             Session::flash('message', 'Password has been changed successfully');
             return Redirect::to('home');
         } else {
             Session::flash('message', 'Old password Incorrect');
             return view('member.password_create');
         }
     }
 }
Example #2
0
 /**
  * Store a newly created resource in storage.
  *
  * @param CreateHistoryRequest $request
  * @return Response
  */
 public function store(CreateHistoryRequest $request)
 {
     $history = new History();
     $history->fill($request->all());
     $history->user_id = Auth::id();
     $history->save();
     $application = Application::findOrFail($history->application->id);
     $application->status = $history->status;
     $application->save();
     $message = trans('messages.application_updated_successfully');
     Flash::info($message);
     return redirect()->route('admin.applications.show', $history->application);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param CreateApplicationRequest $request
  * @return Response
  */
 public function store(CreateApplicationRequest $request)
 {
     $application = new Application();
     $application->fill($request->all());
     $application->user_id = Auth::id();
     $application->status = 'process';
     $application->save();
     $history = new History();
     $history->status = $application->status;
     $history->message = trans('messages.application_sent_successfully');
     $history->user_id = $application->user_id;
     $history->application_id = $application->id;
     $history->save();
     $message = trans('messages.application_sent_successfully');
     Flash::info($message);
     return redirect()->route('applications.show', $application);
 }
 /**
  * Add a beer to a user's cellar with their rating and notes about the beer.
  *
  * @param Request $request
  * @return \Illuminate\Contracts\Routing\ResponseFactory|\Symfony\Component\HttpFoundation\Response
  */
 public function addBeer(Request $request)
 {
     $validator = Validator::make($request->all(), ['beer' => 'required|integer|exists:beers,id', 'rating' => 'required|integer|between:1,5']);
     if ($validator->fails()) {
         return response(['status' => 'failed', 'message' => 'Invalid data.', 'errors' => $validator->errors()->all()], 400);
     }
     // see if a record for the user and beer already exists, we need to warn them to update instead of insert
     $check = History::where('user_id', '=', $this->user->id)->where('beer_id', '=', $request->get('beer'))->get();
     if (count($check) > 0) {
         return response(['status' => 'failed', 'message' => 'This beer already exists in your history.  Did you mean to update the record?'], 400);
     }
     $history = new History();
     $history->user_id = $this->user->id;
     $history->beer_id = $request->get('beer');
     $history->rating = (int) $request->get('rating');
     $history->notes = $request->get('notes');
     $history->save();
     return response(['status' => 'ok', 'message' => 'Your beer rating has been added to your cellar.', 'history' => $history]);
 }
 public function order(Request $request)
 {
     $customer = Customer::where('email', '=', $request->email)->first();
     if (empty($customer)) {
         Session::flash('message', 'Désolé, cet email n\'apparait pas dans notre BDD.');
         return redirect()->back();
     }
     if (Hash::check($request->password, $customer->password)) {
         $history = new History();
         $history->customer_id = $customer->id;
         $history->total = $request->total;
         $history->save();
         Session::flush();
         Session::flash('message', 'Merci pour votre commande !');
         return redirect()->back();
     } else {
         Session::flash('message', 'Désolé, merci de vérifier votre mot de passe.');
         return redirect()->back();
     }
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     if ($id != 0) {
         $resumdel1 = PersonalInformation::where('id', $id)->delete();
         $resumdel2 = EducationalInformation::where('pid', $id)->delete();
         $resumdel3 = WorkInformation::where('pid', $id)->delete();
         $resumdel4 = Language::where('pid', $id)->delete();
         $resumdel5 = SkillsInformation::where('pid', $id)->delete();
         $resumdel = AdditionalInformation::where('pid', $id)->delete();
         $resumdel = UploadInformation::where('pid', $id)->delete();
         $resumdel = PrivacyInformation::where('pid', $id)->delete();
     } else {
         $deleteChecked = Input::get('resume');
         if ($deleteChecked) {
             foreach ($deleteChecked as $delete) {
                 $resumdel1 = PersonalInformation::where('id', $delete)->delete();
                 $resumdel2 = EducationalInformation::where('pid', $delete)->delete();
                 $resumdel3 = WorkInformation::where('pid', $delete)->delete();
                 $resumdel4 = Language::where('pid', $delete)->delete();
                 $resumdel5 = SkillsInformation::where('pid', $delete)->delete();
                 $resumdel = AdditionalInformation::where('pid', $delete)->delete();
                 $resumdel = UploadInformation::where('pid', $delete)->delete();
                 $resumdel = PrivacyInformation::where('pid', $delete)->delete();
             }
             Session::flash('message', 'Successfully deleted');
             $history = new History();
             $history->action_id = 0;
             $history->action = 'Resume deleted';
             $history->user = Auth::user()->name;
             $history->remark = 'Number of Resume deleted=' . count($deleteChecked);
             $history->save();
         } else {
             Session::flash('nrmessage', 'Resume are not Selected');
         }
     }
     return Redirect::to('resume');
 }
 public function savecde()
 {
     $id = Auth::user()->id;
     if (User::find($id)->customer) {
         $customer_id = User::find($id)->customer->id;
         $num_cde = History::orderBy('cde_id', 'desc')->first()->cde_id + 1;
         foreach (Session::get('cde') as $pdts) {
             foreach ($pdts as $pdt) {
                 $product = Product::find($pdt['id']);
                 $h = new History();
                 $h->product_id = $pdt['id'];
                 $h->customer_id = $customer_id;
                 $h->cde_id = $num_cde;
                 $h->price = $product->price;
                 $h->quantity = $pdt['quantity'];
                 $h->command_at = Carbon::now();
                 $h->status = 'finalized';
                 $h->save();
                 $product->quantity -= $pdt['quantity'];
                 $product->save();
             }
         }
         $customer = Customer::find($customer_id);
         $customer->number_command += 1;
         $customer->save();
         Session::forget('cde');
         return redirect('/')->with(['message' => 'Votre commande a bien été validée sous le N° ' . $num_cde, 'alert' => 'success']);
     } else {
         return redirect('/registerCustomer');
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     if (Input::get('resume')) {
         $approveChecked = Input::get('resume');
         if (Auth::user()->type == 1 && Auth::user()->loginas == 1) {
             $records = EmployerApproval::select('pid')->whereIn('apid', $approveChecked)->selectRaw('count(`pid`) as `occurences`')->from('employerapproval')->groupBy('pid')->having('occurences', '>', 1)->get();
             if (count($records) != 0) {
                 Session::flash('message', 'You can not Approve more than one Employer for same Resume');
                 return Redirect::to('approval');
             } else {
                 foreach ($approveChecked as $approve) {
                     $rid = EmployerApproval::where('apid', $approve)->first();
                     $update = DB::table('personalinformation')->where('id', $rid->pid)->update(['approval_status' => 1, 'approved_by' => $rid->empid]);
                 }
                 $history = new History();
                 $history->action_id = Auth::user()->id;
                 $history->action = 'Resume Approved';
                 $history->user = Auth::user()->name;
                 $history->remark = 'Number of resume approved=' . count($approveChecked);
                 $history->save();
                 Session::flash('message', 'Resume Approved Successfully');
             }
         } else {
             foreach ($approveChecked as $approve) {
                 $prvcheck = EmployerApproval::wherePidAndEmpid($approve, Auth::user()->id)->first();
                 if ($prvcheck) {
                 } else {
                     $update = DB::table('personalinformation')->where('id', $approve)->update(['approved_by' => 1]);
                     $insert = new EmployerApproval();
                     $insert->pid = $approve;
                     $insert->empid = Auth::user()->id;
                     $insert->save();
                     Session::flash('message', 'Resume Requested Successfully');
                 }
             }
             if ($insert) {
                 $history = new History();
                 $history->action_id = Auth::user()->id;
                 $history->action = 'Resume Requested';
                 $history->user = Auth::user()->name;
                 $history->remark = 'Number of resume requested=' . count($approveChecked);
                 $history->save();
             }
         }
     }
     return Redirect::to('approval');
 }
 public function block($id)
 {
     $ret = Member::where('id', $id)->first();
     if ($ret->status == 1) {
         $update = \DB::table('members')->where('id', $id)->update(['status' => 0]);
         $history = new History();
         $history->action_id = $id;
         $history->action = 'Member Blocked';
         $history->user = Auth::user()->name;
         $history->remark = '';
         $history->save();
         Session::flash('blockmessage', 'Member has been blocked successfully');
     } else {
         $update = \DB::table('members')->where('id', $id)->update(['status' => 1]);
         $history = new History();
         $history->action_id = $id;
         $history->action = 'Member Unblocked';
         $history->user = Auth::user()->name;
         $history->remark = '';
         $history->save();
         Session::flash('unblockmessage', 'Member has been unblocked successfully');
     }
     Session::flash('memberid', $ret->type);
     return \Redirect::to('member/show');
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $deleteChecked = Input::get('demand');
     if ($deleteChecked) {
         if (Auth::user()->type == 3 || Auth::user()->loginas == 3) {
             foreach ($deleteChecked as $delete) {
                 $insert = new Demanddelete();
                 $insert->userId = Auth::user()->id;
                 $insert->demandId = $delete;
                 $insert->save();
             }
             $history = new History();
             $history->action_id = 0;
             $history->action = 'Demand deleted';
             $history->user = Auth::user()->name;
             $history->remark = 'Number of demand deleted=' . count($deleteChecked);
             $history->save();
             Session::flash('message', 'Demand deleted Successfully');
             return Redirect::to('demand_view');
         } else {
             foreach ($deleteChecked as $delete) {
                 $memdel = DB::table('demand')->whereId($delete)->delete();
             }
             $history = new History();
             $history->action_id = 0;
             $history->action = 'Demand deleted';
             $history->user = Auth::user()->name;
             $history->remark = 'Number of demand deleted=' . count($deleteChecked);
             $history->save();
             Session::flash('message', 'Demand deleted Successfully');
             return Redirect::to('demand');
         }
     }
 }
 private function saveHistory($id, $weight)
 {
     $history = App\History::where('user_id', '=', $id)->where('day', '=', date('Y-m-d'))->get();
     if (!count($history)) {
         $history = new History();
         $history->user_id = $id;
         $history->weight = $weight;
         $history->day = date('Y-m-d');
         $history->save();
     }
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update(Request $request, $id)
 {
     $input = $request->input();
     if (Input::file('company_document')) {
         $company_document = array('file' => Input::file('company_document'), 'extention' => Input::file('company_document')->getClientOriginalExtension());
         $rules = array('file' => 'required|max:2048', 'extention' => 'required|In:pdf,doc,docx,jpeg,bmp,png');
         $validator = Validator::make($company_document, $rules);
         if ($validator->fails()) {
             Session::flash('message', 'File must be less than 2Mb and only pdf,doc,docx,jpeg,bmp,png');
             $agentp = DB::table('members')->whereId($id)->first();
             return view('agent.edit')->with('agentp', $agentp);
         } else {
             $destinationPath = 'upload';
             $companyDocumentExtension = Input::file('company_document')->getClientOriginalExtension();
             $companyDocumentName = rand(11111, 99999) . '_comp_docu' . '.' . $companyDocumentExtension;
             Input::file('company_document')->move($destinationPath, $companyDocumentName);
         }
     }
     $update = DB::table('members')->where('id', $id)->update(['name' => $input['name'], 'address' => $input['address'], 'contactNumber' => $input['contactNumber'], 'email' => $input['email']]);
     $ret = DB::table('memberprofile')->where('uid', $id)->first();
     if ($ret) {
         $mpupdate = DB::table('memberprofile')->where('uid', $id)->update(['company_name' => $input['company_name'], 'company_address' => $input['company_address'], 'company_information' => $input['company_information'], 'company_document' => isset($companyDocumentName) ? $companyDocumentName : '']);
     } else {
         $memprofile = new MemberProfile();
         $memprofile->uid = $id;
         $memprofile->company_name = $input['company_name'];
         $memprofile->company_address = $input['company_address'];
         $memprofile->company_information = $input['company_information'];
         $memprofile->company_document = isset($companyDocumentName) ? $companyDocumentName : '';
         $memprofile->save();
     }
     $rethistory = History::whereAction_idAndAction($id, 'Profile Updated')->first();
     if ($rethistory) {
         $history = History::find($rethistory->id);
         $history->action = 'Profile Updated';
         $history->user = Auth::user()->name;
         $history->remark = '';
         $history->save();
     } else {
         $history = new History();
         $history->action_id = $id;
         $history->action = 'Profile Updated';
         $history->user = Auth::user()->name;
         $history->remark = '';
         $history->save();
     }
     Session::flash('message', 'Updated successfully');
     return Redirect::to('home');
 }