/** @test */
 public function a_visitor_can_request_to_be_registered()
 {
     $id = RegistrationRequestId::generate();
     $this->scenario->when(function () use($id) {
         return RegistrationRequest::submit($id, new FullName('Mark', '', 'Redeman'), Gender::fromString('male'), new DateTimeImmutable('1993-04-26'), ContactInfo::describe(new Email('*****@*****.**'), new Address('Groningen', '9742GS', 'Plutolaan 11')), new StudyDetails('Msc Applied Mathematics', new DateTimeImmutable('2011-09-01'), 's2218356'), new PaymentInfo(true, true));
     })->then([new RegistrationRequestSubmitted($id, new FullName('Mark', '', 'Redeman'), Gender::fromString('male'), new DateTimeImmutable('1993-04-26'), ContactInfo::describe(new Email('*****@*****.**'), new Address('Groningen', '9742GS', 'Plutolaan 11')), new StudyDetails('Msc Applied Mathematics', new DateTimeImmutable('2011-09-01'), 's2218356')), new PaymentInfoProvided($id, new PaymentInfo(true, true))]);
 }
 public static function fromRequest(Request $request)
 {
     $name = new FullName($request->input('firstname'), $request->input('middlename'), $request->input('surname'));
     $birthdate = DateTimeImmutable::createFromFormat('Y-m-d', $request->input('birthdate'));
     $gender = Gender::fromString($request->input('gender'));
     $studyDetails = new StudyDetails($request->input('study'), DateTimeImmutable::createFromFormat('Y-m', $request->input('starting-date-study')), $request->input('student-number'));
     $contactOptions = [];
     return new SubmitRegistrationRequest(RegistrationRequestId::generate(), $name, $birthdate, $gender, $studyDetails, $contactOptions);
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $repo = App::make(Repository::class);
     $faker = App::make(Faker\Generator::class);
     $genders = ['male', 'female'];
     for ($i = 0; $i < 10; $i++) {
         $id = RegistrationRequestId::generate();
         $gender = $faker->randomElement($genders);
         $request = RegistrationRequest::submit($id, new FullName($faker->firstName($gender), '', $faker->lastName), Gender::fromString($gender), DateTimeImmutable::createFromMutable($faker->dateTimeInInterval('- 30 years', '-16 years')), ContactInfo::describe(new Email($faker->safeEmail), new Address($faker->city, $faker->postCode, $faker->streetAddress)), new StudyDetails('Msc Applied Mathematics', new DateTimeImmutable('2011-09-01'), 's2218356'), new PaymentInfo(true, $faker->boolean));
         $repo->save($request);
     }
 }
 public function submitRequest(Request $request, Repository $repo)
 {
     // Gather all the given inputs and put them into value objects
     // that are needed by the SubmitRegistrationRequest command
     $name = $this->fullNameFrom($request);
     $birthdate = $this->birthdateFrom($request);
     $gender = $this->genderFrom($request);
     $studyDetails = $this->studyDetailsFrom($request);
     $contactInfo = $this->contactInfoFrom($request);
     $paymentInfo = $this->paymentInfoFrom($request);
     $command = new SubmitRegistrationRequest(RegistrationRequestId::generate(), $name, $birthdate, $gender, $studyDetails, $contactInfo, $paymentInfo);
     // $command = SubmitRegistrationRequest::fromRequest($request);
     $this->dispatch($command);
     return back()->withInput();
 }
 protected function createInstance()
 {
     $id = RegistrationRequestId::generate();
     $paymentInfo = new PaymentInfo(true, true);
     return new PaymentInfoProvided($id, $paymentInfo);
 }
 protected function createInstance()
 {
     return $this->registrationRequestSubmitted(RegistrationRequestId::generate());
 }
 protected function createInstance()
 {
     return new RequestStatus(RegistrationRequestId::generate(), 'Mark Redeman', true, true, true, false, new DateTimeImmutable());
 }