public function store()
 {
     $userManager = new UserManagement();
     if (!$this->customerAddValidator->validate(Input::all())) {
         Session::flash('error_msg', Utils::buildMessages($this->customerAddValidator->getValidation()->messages()->all()));
         return Redirect::to('/departments/admins/create')->withInput(Input::except("avatar"));
     } else {
         try {
             $user = $userManager->createUser(["name" => Input::get("name"), "email" => Input::get("email"), "password" => Input::get("password"), "password_confirmation" => Input::get("password_confirmation"), "birthday" => Input::get("birthday"), "bio" => Input::get("bio"), "mobile_no" => Input::get("mobile_no"), "country" => Input::get("country"), "gender" => Input::get("gender"), "timezone" => Input::get("timezone", ""), "show_avatar" => Input::has("show_avatar"), "permissions" => Input::has('permissions') ? implode(",", Input::get('permissions')) : "", "avatar" => Input::hasFile('avatar') ? Utils::imageUpload(Input::file('avatar'), 'profile') : ''], 'department-admin', Input::has("activated"));
             $company_department_admin = new CompanyDepartmentAdmins();
             $company_department_admin->user_id = $user->id;
             $company_department_admin->company_id = Input::get('company');
             $company_department_admin->save();
             if (Input::get('department') > 0) {
                 $department_admin = new DepartmentAdmins();
                 $department_admin->user_id = $user->id;
                 $department_admin->department_id = Input::get('department');
                 $department_admin->save();
             }
             $this->mailer->welcome($user->email, $user->name, User::getWelcomeFields(false, $user->id, Input::get("password"), Input::get('company')));
             RecentActivities::createActivity("Department Admin Name:" . $user->name . " , ID:" . $user->id . " created by User ID:" . Auth::user()->id . " User Name:'" . Auth::user()->name);
             if (!Input::has("activated")) {
                 $this->mailer->activate($user->email, $user->name, User::getActivateFields(false, $user->id, Input::get('company')));
             }
             Session::flash('success_msg', trans('msgs.department_admin_created_success'));
             return Redirect::to('/departments/admins/all');
         } catch (\Exception $e) {
             Session::flash('error_msg', trans('msgs.unable_to_create_department_admin'));
             return Redirect::to('/departments/admins/create')->withInput(Input::except("avatar"));
         }
     }
 }
 public function store()
 {
     $userManager = new UserManagement();
     $this->accountAddValidator->addRule("company", "required");
     if (!$this->accountAddValidator->validate(Input::all())) {
         Session::flash('error_msg', Utils::buildMessages($this->accountAddValidator->getValidation()->messages()->all()));
         return Redirect::to('/customers/create')->withInput(Input::except("avatar"));
     } else {
         try {
             $user = $userManager->createUser(["name" => Input::get("name"), "email" => Input::get("email"), "password" => Input::get("password"), "password_confirmation" => Input::get("password_confirmation"), "birthday" => Input::get("birthday"), "bio" => Input::get("bio"), "mobile_no" => Input::get("mobile_no"), "country" => Input::get("country"), "gender" => Input::get("gender"), "avatar" => Input::hasFile('avatar') ? Utils::imageUpload(Input::file('avatar'), 'profile') : ''], 'customer', Input::has("activated"));
             $company_users = new CompanyCustomers();
             $company_users->customer_id = $user->id;
             $company_users->company_id = Input::get("company");
             $company_users->save();
             $this->mailer->welcome($user->email, $user->name, User::getWelcomeFields(false, $user->id, Input::get("password"), Input::get('company')));
             RecentActivities::createActivity("Customer <a href='/customers/all'>ID:" . $user->id . "</a> created by User ID:" . Auth::user()->id . " User Name:" . Auth::user()->name);
             if (!Input::has("activated")) {
                 $this->mailer->activate($user->email, $user->name, User::getActivateFields(false, $user->id, Input::get('company')));
             }
             Session::flash('success_msg', trans('msgs.customer_created_success'));
             return Redirect::to('/customers/all');
         } catch (\Exception $e) {
             Session::flash('error_msg', trans('msgs.unable_to_add_customer'));
             return Redirect::to('/customers/create')->withInput(Input::except("avatar"));
         }
     }
 }
 public function store()
 {
     $userManager = new UserManagement();
     if (!$this->accountAddValidator->validate(Input::all())) {
         Session::flash('error_msg', Utils::buildMessages($this->accountAddValidator->getValidation()->messages()->all()));
         return Redirect::to('/accounts/create')->withInput(Input::except("avatar"));
     } else {
         try {
             $userManager->createUser(["name" => Input::get("name"), "email" => Input::get("email"), "password" => Input::get("password"), "password_confirmation" => Input::get("password_confirmation"), "birthday" => Input::get("birthday"), "bio" => Input::get("bio"), "mobile_no" => Input::get("mobile_no"), "country" => Input::get("country"), "gender" => Input::get("gender"), "avatar" => Input::hasFile('avatar') ? Utils::imageUpload(Input::file('avatar'), 'profile') : ''], 'admin', Input::has("activated"));
             Session::flash('success_msg', trans('users.account_created_success'));
             return Redirect::to('/accounts/all');
         } catch (\Exception $e) {
             Session::flash('error_msg', trans('users.account_not_found'));
             return Redirect::to('/accounts/create')->withInput(Input::except("avatar"));
         }
     }
 }