コード例 #1
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(CreateUserRequest $request, User $user)
 {
     $password = $request->password;
     $user = new User();
     $request->offsetSet('password', bcrypt($request->password));
     $request->offsetSet('created_by', Auth::user()->id);
     $request->offsetSet('updated_by', Auth::user()->id);
     $request->offsetSet('status', "NEW");
     if ($request->role_id != 2) {
         $request->offsetSet('manager_id', 0);
     }
     $user->create($request->all());
     $user = DB::table('users')->where('email', $request->email)->first();
     $goal = parent::assembleGoalSetting();
     $goal->user_id = $user->id;
     $goal->save();
     $message = 'You have successfully Created ' . $user->last_name . ', ' . $user->first_name;
     //\Session::flash('message','You have successfully Created '. $user->last_name . ', ' . $user->first_name);
     $users = $users = $this->getActiveUsers();
     $keyword = '';
     $userPassword = new UserPassword();
     $userPassword->user_id = $user->id;
     $userPassword->crypt_password = \Crypt::encrypt($password);
     $userPassword->updated_at = new \DateTime();
     $userPassword->save();
     $contactEmail = $user->email;
     $contactName = $user->first_name . ' ' . $user->last_name;
     Mail::send('emails.hello', array('first_name' => $user->first_name, 'user_name' => $user->email, 'password' => $password), function ($message) use($contactEmail, $contactName) {
         $message->from('*****@*****.**', 'Sales Performance Indicator');
         $message->to($contactEmail, $contactName)->subject('Welcome to Sales Performance Indicator!');
     });
     \Session::flash('message', 'You have successfully Created ' . $user->last_name . ', ' . $user->first_name);
     return view('user.list', compact('users', 'keyword'));
 }
コード例 #2
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Requests\CreateUserRequest $request, User $user)
 {
     $license = License::whereRaw('company_id = ? and status = "ACTIVE" and user_id = 0', array(Auth::user()->company_id))->first();
     if (!isset($license->id)) {
         \Session::flash('message', 'You have not Licenses');
         return Redirect::action('CompanyUserController@index');
     }
     $password = $request->password;
     $user = new User();
     $request->offsetSet('password', bcrypt($request->password));
     $request->offsetSet('created_by', Auth::user()->id);
     $request->offsetSet('updated_by', Auth::user()->id);
     $request->offsetSet('status', "NEW");
     if ($request->role_id != 2) {
         $request->offsetSet('manager_id', 0);
     }
     if (Auth::user()->role->id == 3) {
         $request->offsetSet('manager_id', Auth::user()->id);
     }
     $user->create($request->all());
     $user = DB::table('users')->where('email', $request->email)->first();
     $userPassword = new UserPassword();
     $userPassword->user_id = $user->id;
     $userPassword->crypt_password = \Crypt::encrypt($password);
     $userPassword->updated_at = new \DateTime();
     $userPassword->created_at = new \DateTime();
     $userPassword->save();
     $goal = parent::assembleGoalSetting();
     $goal->user_id = $user->id;
     $goal->created_by = Auth::user()->id;
     $goal->updated_by = Auth::user()->id;
     $goal->save();
     $license->user_id = $user->id;
     $license->update();
     $contactEmail = $user->email;
     Mail::send('emails.hello', array('first_name' => $user->first_name, 'user_name' => $user->email, 'password' => $password), function ($message) use($contactEmail) {
         $message->from('*****@*****.**', 'Sales Performance Indicator');
         $message->to($contactEmail, 'Sales Performance Indicator')->subject('Welcome to Sales Performance Indicator!');
     });
     \Session::flash('message', 'You have successfully created ' . $user->last_name . ', ' . $user->first_name);
     return Redirect::action('CompanyUserController@index');
 }