Example #1
0
 /**
  * Determine if specification was satisfied by given candidate
  * 
  * @param  SpecificationCandidate $candidate
  * @return boolean
  */
 public function isSatisfiedBy(SpecificationCandidate $candidate)
 {
     if ($user = $this->userRepository->findByUsername($candidate->value())) {
         if (!$user->id()->equal($this->id)) {
             return false;
         }
     }
     return true;
 }
Example #2
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]);
 }
Example #3
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]);
 }