Пример #1
0
 public function postRegister(Request $request)
 {
     $rules = ['name' => 'required', 'email' => 'required|email|unique:users,email', 'password' => 'required|min:5', 'signup_confirm' => 'required'];
     $request->old('name');
     $request->old('email');
     $validator = Validator::make($request->all(), $rules);
     if ($validator->fails()) {
         $message = $validator->messages();
         return Redirect::route('register')->withInput()->withErrors($message);
     }
     $user = new User();
     $user->name = $request->get('name');
     $user->email = $request->get('email');
     $user->password = Hash::make($request->get('password'));
     $user->save();
     $currentUser = User::orderBy('id', 'Desc')->first();
     $userId = new UserProfile();
     $userId->user_id = $currentUser['id'];
     $userId->save();
     Session::flash('register-successful', 'User has been successfully registered');
     return Redirect::route('register');
 }
Пример #2
0
 public function getImage()
 {
     $userProfile = UserProfile::where('user_id', Auth::user()->id)->first();
     return $userProfile->image;
 }
 public function deactivateAccount()
 {
     $userProduct = User_Product::select('products_id')->join('products', 'products.id', '=', 'user_product.products_id')->where('user_product.user_id', Auth::user()->id)->get()->count();
     if ($userProduct > 0) {
         $message = 'If You Want to deactivate Your Account Please Delete All Products First...!!';
         return Redirect::route('user-profile')->withErrors($message);
     } else {
         $user = User::where('id', Auth::user()->id)->delete();
         $userProfile = UserProfile::where('user_id', Auth::user()->id)->delete();
         return Redirect::route('register');
     }
 }