Esempio n. 1
0
 /**
  * Attach permission to role
  * 
  * @param  Inoplate\Account\Domain\Commands\Models $administrator
  * @return void
  */
 protected function attachPermissionToRole($role)
 {
     $permissions = $this->permissionRepository->all();
     foreach ($permissions as $permission) {
         $this->bus->dispatch(new Commands\AttachPermissionToRole($role->id()->value(), $permission->id()->value()));
     }
 }
Esempio n. 2
0
 public function delete(Bus $bus, $ids)
 {
     $ids = explode(',', $ids);
     foreach ($ids as $id) {
         $bus->dispatch(new Commands\DeleteRole($id));
     }
     return $this->formSuccess(route('account.admin.roles.index.get'), ['message' => trans('inoplate-account::messages.role.deleted')]);
 }
Esempio n. 3
0
 /**
  * Handle event
  * 
  * @param  LibraryWasSharedToAuthor $event
  * @return void
  */
 public function handle(LibraryWasSharedToAuthor $event)
 {
     $author = $event->author;
     $library = $event->library;
     $userId = $author->id()->value();
     $owner = $library->owner();
     $message = trans('inoplate-media::messages.library.notification.share', ['owner' => $owner->name()->value(), 'library' => $library->description()->value()['title']]);
     $notifyDriver = config('inoplate.media.notifier');
     $this->bus->dispatch(new NotifyUser($userId, $message, $notifyDriver));
 }
 public function putConfirm($token, Dispatcher $bus)
 {
     $email = $this->emailResetRepository->findByToken($token);
     if (is_null($email)) {
         abort(404);
     }
     $user = $this->userRepository->findById($email->user_id);
     $userId = $user->id()->value();
     $bus->dispatch(new DescribeUser($userId, $user->username()->value(), $email->email));
     $this->emailResetRepository->remove($userId);
     event(new NewUserEmailWasConfirmed($userId));
     return redirect('/')->with('message', trans('account::message.profile.email_changed'));
 }
Esempio n. 5
0
 public function putUpdateAvatar(Dispatcher $bus, Request $request, UserRepository $userRepository, LibraryRepository $libraryRepository, $id)
 {
     $userId = $this->authis->check('account.admin.users.update.get') ? $id : $request->user()->id;
     $library = $libraryRepository->findByPath($request->avatar);
     $user = $userRepository->findById($userId)->toArray();
     $description = $user['description'];
     $this->validate($request, ['avatar' => 'required']);
     $description['avatar'] = $request->avatar;
     $bus->dispatch(new DescribeUser($userId, $user['username'], $user['email'], $description));
     if ($library) {
         $library = $library->toArray();
         $libraryDescription = $library['description'];
         $libraryDescription['visibility'] = 'public';
         $bus->dispatch(new DescribeLibrary($library['id'], $libraryDescription));
     }
     return $this->formSuccess(route('account.admin.profile.index.get'), ['message' => trans('inoplate-account::messages.profile.avatar_updated')]);
 }
Esempio n. 6
0
 /**
  * Init user
  * 
  * @param  Inoplate\Account\Domain\Commands\Models $administrator
  * @return void
  */
 protected function initUser($administrator)
 {
     $email = $this->ask('Email?', '*****@*****.**');
     $username = $this->ask('Username?', 'admin');
     $name = $this->ask('Name?', 'Administrator');
     $password = $this->secret('Password?');
     $this->bus->dispatch(new Commands\RegisterNewUser($username, $email, [$administrator->id()->value()], ['password' => bcrypt($password), 'name' => $name, 'active' => true]));
 }
 protected function markAsViewed(Bus $bus, $userId)
 {
     $bus->dispatch(new MarkNotificationAsViewed($userId));
 }
Esempio n. 8
0
 public function delete(Bus $bus, $library)
 {
     $id = $library->id;
     $library = $this->libraryRepository->findById(new MediaDomainModels\LibraryId($id));
     $bus->dispatch(new Commands\DeleteLibrary($id));
     return $this->formSuccess(route('media.admin.libraries.index.get'), ['message' => trans('inoplate-media::messages.library.deleted'), 'library' => $library->toArray()]);
 }
Esempio n. 9
0
 public function store(Request $request, Bus $bus, UserRepository $userRepository)
 {
     $this->validate($request, ['reg_no' => 'required|max:255|unique:lecturers', 'local_reg_no' => 'required|max:255|unique:lecturers', 'name' => 'required|max:255', 'id_number' => 'unique:lecturers', 'country_id' => 'exists:countries,id']);
     $lecturer = new Lecturer();
     $lecturer->reg_no = $request->reg_no;
     $lecturer->local_reg_no = $request->local_reg_no;
     $lecturer->name = $request->name;
     $lecturer->status = $request->status;
     $lecturer->id_number = $request->id_number;
     $lecturer->mother_maiden_name = $request->mother_maiden_name;
     $lecturer->country_id = $request->country_id;
     $lecturer->avatar = $request->avatar;
     $user = $userRepository->findByUsername($request->reg_no);
     if (!$user) {
         $role = Role::where('name', 'Lecturer')->first();
         $roles = $role ? [$role->id] : [];
         $desc = ['password' => bcrypt($request->reg_no), 'name' => $request->name, 'active' => true];
         $bus->dispatch(new RegisterNewUser($request->reg_no, $request->reg_no . '@email.com', $roles, $desc));
         $user = $userRepository->findByUsername($request->reg_no);
     }
     $lecturer->user_id = $user->id()->value();
     $lecturer->save();
     return $this->formSuccess(route('admin.employee.lecturer.index', ['id' => $lecturer->id]), ['message' => 'Dosen berhasil disimpan', 'lecturer' => $lecturer]);
 }
Esempio n. 10
0
 protected function detachPermissionFromRole(Bus $bus, $roleId, $permissionId)
 {
     $bus->dispatch(new Commands\DetachPermissionFromRole($roleId, $permissionId));
     return $this->formSuccess(route('account.admin.permissions.index.get'), ['message' => trans('inoplate-account::messages.permissions.detached')]);
 }
Esempio n. 11
0
 protected function revokeRoleFromUser(Bus $bus, $userId, array $grantedRoles, array $plannedGrantedRoles)
 {
     foreach ($grantedRoles as $key => $role) {
         if (!in_array($role['id'], $plannedGrantedRoles)) {
             $bus->dispatch(new Commands\RevokeRoleFromUser($userId, $role['id']));
         }
     }
 }
Esempio n. 12
0
 public function store(Request $request, Bus $bus, UserRepository $userRepository)
 {
     $this->validate($request, ['reg_no' => 'required|max:255|unique:students', 'name' => 'required|max:255', 'entry_year' => 'required', 'program_id' => 'required|exists:programs,id', 'id_number' => 'unique:students', 'country_id' => 'exists:countries,id']);
     $student = new Student();
     $student->reg_no = $request->reg_no;
     $student->name = $request->name;
     $student->entry_year = $request->entry_year;
     $student->program_id = $request->program_id;
     $student->id_number = $request->id_number;
     $student->mother_maiden_name = $request->mother_maiden_name;
     $student->country_id = $request->country_id;
     $student->avatar = $request->avatar;
     $user = $userRepository->findByUsername($request->reg_no);
     if (!$user) {
         $role = Role::where('name', 'Student')->first();
         $roles = $role ? [$role->id] : [];
         $desc = ['password' => bcrypt($request->reg_no), 'name' => $request->name, 'active' => true];
         $bus->dispatch(new RegisterNewUser($request->reg_no, $request->reg_no . '@email.com', $roles, $desc));
         $user = $userRepository->findByUsername($request->reg_no);
     }
     $student->user_id = $user->id()->value();
     $student->save();
     return $this->formSuccess(route('admin.student.student.index', ['id' => $student->id]), ['message' => 'Mahasiswa berhasil disimpan', 'student' => $student]);
 }
 /**
  * Boot command
  * 
  * @param  Dispatcher $dispatcher
  * @return void
  */
 public function boot(Dispatcher $dispatcher)
 {
     $dispatcher->maps($this->commands);
 }