Exemplo n.º 1
0
 public function run()
 {
     Role::create(['name' => 'Super Admin']);
     Role::create(['name' => 'SaaS Client Admin']);
     Role::create(['name' => 'Candidate']);
     Role::create(['name' => 'Agency Admin']);
     Role::create(['name' => 'Agent']);
 }
Exemplo n.º 2
0
 private function createUserWithRoles()
 {
     if ($this->user) {
         return $this->user;
     }
     $user = User::create(['username' => 'testUser', 'email' => '*****@*****.**', 'password' => 'password']);
     with(new RolesTableSeeder())->run();
     $user->roles()->attach(Role::lists('id'));
     $this->user = $user;
     return $user;
 }
Exemplo n.º 3
0
 public function showWelcome()
 {
     Auth::login(User::find(1));
     dd(Auth::user()->hasMtmRole(Role::findByName('Agency Admin')));
     dd(Agency::findByName('Dietrich, Koelpin and Weissnat'));
     $model = Agency::first();
     echo $model->hasMtmUser(User::find(1), 'admins');
     // dd($this->get_class());
     // dd($this->getActionPermissions(get_class($this)));
     // return View::make('hello');
 }
Exemplo n.º 4
0
 public function register_agency()
 {
     $success = false;
     $user = Input::only('email', 'password', 'confirm_password', 'first_name', 'last_name');
     $user['username'] = $user['email'];
     //        $user['confirmation_code'] = $confirmation_code =  str_random(30);
     Log::info(print_r($user, true));
     try {
         if ($this->userValidator->validate($user)) {
             $newUser = User::create($user);
             $success = $newUser == true;
             $newUser->roles()->attach(Role::findByName('Agency Admin')->id);
             $agency['name'] = Input::get('agency_name');
             $agency['description'] = 'new agency';
             // try {
             if ($this->agencyValidator->validate($agency)) {
                 Log::info($agency);
                 $newAgency = Agency::create($agency);
                 $newAgency->admins()->attach($newUser->id);
             }
             // } catch (FormValidationException $e) {
             // Log::info(print_r($e->getErrors()));
             // return \Response::json(['success' => false, 'error' => $e->getErrors()]);
             // }
         }
     } catch (FormValidationException $e) {
         return \Response::json(['success' => false, 'errors' => $e->getErrors(), 400]);
     }
     Log::info(print_r($user, true));
     if ($success) {
         $newUser->confirmation_code = Hash::make($newUser->id . str_random(30));
         $newUser->save();
         Mail::send('emails.registration.confirmation', ['confirmation' => base64_encode($newUser->confirmation_code) . '?next_step=3&user_id=' . $newUser->id, 'client_base_url' => Input::get('client_base_url')], function ($message) {
             $message->to(Input::get('email'))->subject('Verify your email address');
         });
     }
     return \Response::json(['success' => $success]);
 }
Exemplo n.º 5
0
 /**
  * Create Agent
  * @return \Illuminate\Http\JsonResponse
  */
 public function create()
 {
     $success = false;
     if ($this->validator->validate(\Input::all()) && $this->userValidator->validate(['email' => \Input::get('email'), 'password' => \Str::random(8)])) {
         $user = User::create(['email' => \Input::get('email'), 'username' => \Input::get('name'), 'password' => \Str::random(8)]);
         $agentData = \Input::all();
         $agentData['user_id'] = $user->id;
         // TODO: save uploaded image :|
         // Destination path for uplaoded files which is at /public/uploads
         $destinationPath = public_path() . '/uploads/img/';
         // Handle profile Picture
         if (Input::hasFile('profile_pic_filename')) {
             $file = Input::file('profile_pic_filename');
             $propic_filename = str_random(6) . '_' . str_replace(' ', '_', $file->getClientOriginalName());
             $uploadSuccess = $file->move($destinationPath, $propic_filename);
             if ($uploadSuccess) {
                 $agentData['profile_pic_filename'] = $propic_filename;
             }
         }
         $agent = Agent::create($agentData);
         // Send Invitation Email
         $invitation_code = bin2hex(openssl_random_pseudo_bytes(16));
         $invite = Invite::create(['code' => $invitation_code, 'email' => Input::get('email'), 'user_id' => $user->id, 'user_type' => 'Agent']);
         Mail::send('emails.invitation.invite', ['confirmation' => $invitation_code, 'client_base_url' => 'http://d.motibu-head.com/'], function ($message) {
             $message->to(Input::get('email'))->subject('You have been invited to motibu.com');
         });
         $user->roles()->attach(Role::findByName('Agent')->id);
         $success = $user && $agent;
     }
     return \Response::json(['success' => $success, 'data' => $agent->getTransformed(new AgentTransformer())]);
 }