示例#1
0
 /**
  * Create a new user using register page and store data in this function.
  *
  */
 public function createuser()
 {
     $confirmation_code = str_random(30);
     $v = Validator::make(Request::all(), ['name' => 'required|max:255', 'email' => 'required|email|max:255|unique:users', 'password' => 'required|confirmed|min:6']);
     if ($v->fails()) {
         return redirect()->back()->withErrors($v->errors())->withInput();
     } else {
         $user = new User();
         $user->name = Request::get('name');
         $user->email = Request::get('email');
         $user->type = Request::get('type');
         $user->password = bcrypt(Request::get('password'));
         $user->confirmation_code = $confirmation_code;
         $user->save();
         $gInfo = new Generalinfo();
         $gInfo->user_id = $user->id;
         $gInfo->country_id = Request::get('country');
         $gInfo->city = Request::get('city');
         $gInfo->address = Request::get('address');
         $gInfo->phone = Request::get('phone');
         $gInfo->anotherphone = Request::get('anotherphone');
         $gInfo->skypename = Request::get('skypename');
         $gInfo->howhearaboutus = Request::get('howhearaboutus');
         $gInfo->dob = Request::get('dob');
         // if (Request::hasFile('image')) {
         // 	$destination= 'uploads/';
         // 	$imagename=str_random(6)."_".Request::file('image')->getClientOriginalName();
         // 	Request::file('image')->move($destination,$imagename);
         // 	$gInfo->image=$imagename;
         // }
         $gInfo->save();
         $userInterest = new UserInterest();
         $userInterest->user_id = $user->id;
         $userInterest = Request::get('interest');
         foreach ($userInterest as $userInterest_id) {
             //echo $userInterest_id;
             DB::insert('INSERT INTO user_interests (interest_id, user_id) VALUES (?,?)', array($userInterest_id, $user->id));
         }
         $pInfo = new Professionalinfo();
         $pInfo->user_id = $user->id;
         $pInfo->currentjob = Request::get('currentjob');
         $pInfo->title = Request::get('title');
         $pInfo->startwork_at = Request::get('startwork_at');
         $pInfo->companywebsite = Request::get('companywebsite');
         $pInfo->d_maker = Request::get('d_maker');
         $pInfo->colleage = Request::get('colleage');
         $pInfo->degree = Request::get('degree');
         $pInfo->graduated_at = Request::get('graduated_at');
         $pInfo->fax = Request::get('fax');
         $pInfo->facebook = Request::get('facebook');
         $pInfo->twitter = Request::get('twitter');
         $pInfo->linkedIn = Request::get('linkedIn');
         $pInfo->ownwebsite = Request::get('ownwebsite');
         $pInfo->language = Request::get('language');
         $pInfo->save();
         if ($user->type == "company") {
             $companyInfo = new Company();
             $companyInfo->user_id = $user->id;
             $companyInfo->save();
             // return redirect('companies');
         }
         $data['email'] = Request::get('email');
         $data['name'] = Request::get('name');
         $data['confirmation_code'] = $confirmation_code;
         Mail::send('emails.welcome', $data, function ($message) use($data) {
             $message->from('*****@*****.**', "Wavexpo");
             $message->subject("Welcome to Wavexpo Please visit our website to continu you information");
             $message->to($data['email']);
         });
         return redirect('/register/redirect');
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     //
     $v = Validator::make(Request::all(), ['name' => 'required|max:255', 'email' => 'required|email|max:255|unique:users', 'password' => 'required|confirmed|min:6']);
     if ($v->fails()) {
         return redirect()->back()->withErrors($v->errors())->withInput();
     } else {
         $user = new User();
         $user->name = Request::get('name');
         $user->email = Request::get('email');
         $user->type = Request::get('type');
         $user->password = bcrypt(Request::get('password'));
         $user->save();
         $gInfo = new Generalinfo();
         $gInfo->user_id = $user->id;
         $gInfo->save();
         $pInfo = new Professionalinfo();
         $pInfo->user_id = $user->id;
         $pInfo->save();
         $data['email'] = Request::get('email');
         $data['name'] = Request::get('name');
         // Mail::send('emails.welcome', $data, function($message) use ($data)
         //           {
         //               $message->from('*****@*****.**', "Wavexpo");
         //               $message->subject("Welcome to Wavexpo Please visit our website to continu you information");
         //               $message->to($data['email']);
         //           });
         //return redirect()->action('UserFilesController@store', [$user->id,]);
         // File Storage
         $file = new File();
         $file->name = Request::get('filename');
         $file->desc = Request::get('desc');
         $file->type = Request::get('filetype');
         if (Request::hasFile('file')) {
             $destination = 'files/';
             $filename = str_random(6) . "_" . Request::file('file')->getClientOriginalName();
             Request::file('file')->move($destination, $filename);
             $file->file = $filename;
         } else {
             $file->file = Request::get('file');
         }
         $file->save();
         $userfile = new UserFile();
         $userfile->user_id = $user->id;
         $userfile->file_id = $file->id;
         $userfile->save();
         return redirect('users');
     }
 }
 public function editImage($id)
 {
     //authorization
     if (!$this->adminAuth() && !$this->userAuth(Auth::User()->id)) {
         return view('errors.404');
     }
     $user = Generalinfo::where('user_id', $id)->get();
     return view('generalinfos.editimage', compact('user'));
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     //
     $v = Validator::make(Request::all(), ['city' => 'required|max:30', 'dob' => 'required', 'phone' => 'required']);
     if ($v->fails()) {
         return redirect()->back()->withErrors($v->errors())->withInput();
     } else {
         $userId = Request::get('id');
         $gInfo = Generalinfo::where('user_id', $userId)->get();
         $gInfoId = $gInfo[0]->id;
         $gInfo = Generalinfo::find($gInfoId);
         $gInfo->country_id = Request::get('country');
         $gInfo->city = Request::get('city');
         $gInfo->dob = Request::get('dob');
         $gInfo->image = Request::get('image');
         $gInfo->address = Request::get('address');
         $gInfo->phone = Request::get('phone');
         $gInfo->anotherphone = Request::get('anotherphone');
         $gInfo->skypename = Request::get('skypename');
         $gInfo->howhearaboutus = Request::get('howhearaboutus');
         $gInfo->save();
         $interestId = Request::get('interest');
         // UserInterest::where('user_id',$userId)->update['interest_id'=>$interestId];
         UserInterest::where('user_id', $userId)->update(['interest_id' => $interestId]);
         return redirect('generalinfos/' . $userId);
     }
 }