Exemple #1
0
 /**
  * Save new meeting.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['name' => 'required|max:255', 'email' => 'required|email', 'datetimes' => 'array', 'datetimes.*' => 'date_format:Y-m-d H:i|after:now']);
     Mail::send('emails.meeting', $request->toArray(), function ($m) {
         $m->from('*****@*****.**', 'Meeting Request App')->to(env('MAIL_OWNER'))->subject('New Meeting Request');
     });
     $this->schedule->storeRequest($request);
     return redirect('/')->with('request_sent', true);
 }
 /**
  * On specific day reminder action should be listed
  */
 public function test_list_reminder_on_day()
 {
     // emulate config set
     $expected = [1, 2];
     $expectedStr = implode(',', $expected);
     \Config::set('custom.remindOnDays', $expectedStr);
     $user = factory(User::class, 'admin')->create();
     $companyOne = factory(Company::class)->create();
     $companyTwo = factory(Company::class)->create();
     $this->seeInDatabase('companies', ['id' => $companyOne->id, 'name' => $companyOne->name, 'licence_expire_at' => null])->seeInDatabase('companies', ['id' => $companyTwo->id, 'name' => $companyTwo->name, 'licence_expire_at' => null])->actingAs($user)->visit('/company/' . $companyOne->id . '/edit')->see($companyOne->name)->see('name="licence_expire_at"')->type('2016-04-30', 'licence_expire_at')->press('Save Edit')->seeInDatabase('companies', ['id' => $companyOne->id, 'licence_expire_at' => '2016-04-30', 'is_suspended' => false])->seeInDatabase('schedules', ['who_object' => Company::class, 'who_id' => $companyOne->id, 'run_at' => '2016-04-29', 'action' => ActionCommandSendReminderEmailCommand::class])->seeInDatabase('schedules', ['who_object' => Company::class, 'who_id' => $companyOne->id, 'run_at' => '2016-04-28', 'action' => ActionCommandSendReminderEmailCommand::class]);
     $this->visit('/company/' . $companyTwo->id . '/edit')->see($companyTwo->name)->see('name="licence_expire_at"')->type('2016-04-30', 'licence_expire_at')->press('Save Edit')->seeInDatabase('companies', ['id' => $companyTwo->id, 'licence_expire_at' => '2016-04-30', 'is_suspended' => false])->seeInDatabase('schedules', ['who_object' => Company::class, 'who_id' => $companyTwo->id, 'run_at' => '2016-04-29', 'action' => ActionCommandSendReminderEmailCommand::class])->seeInDatabase('schedules', ['who_object' => Company::class, 'who_id' => $companyTwo->id, 'run_at' => '2016-04-28', 'action' => ActionCommandSendReminderEmailCommand::class]);
     $repository = new ScheduleRepository();
     $date = new Carbon('2016-04-28');
     $list = $repository->getActionsForDate($date);
     $this->assertCount(2, $list);
     $list = $repository->getNewActionsForDate($date);
     $this->assertCount(2, $list);
 }
 public function test_remove_all_schedule_for_one_company()
 {
     $companyOne = factory(Company::class)->create();
     $companyTwo = factory(Company::class)->create();
     $scheduleOne = factory(Schedule::class)->create(['who_object' => Company::class, 'who_id' => $companyOne->id]);
     $scheduleTwo = factory(Schedule::class)->create(['who_object' => Company::class, 'who_id' => $companyTwo->id]);
     // check is saved correctly to DB
     $this->seeInDatabase('schedules', ['id' => $scheduleOne->id, 'who_object' => Company::class, 'who_id' => $companyOne->id]);
     $this->seeInDatabase('schedules', ['id' => $scheduleTwo->id, 'who_object' => Company::class, 'who_id' => $companyTwo->id]);
     // remove reminders for Company One
     $scheduleRepository = new ScheduleRepository();
     $scheduleRepository->removeAllForObject($companyOne);
     // check is one removed from DB
     $this->dontSeeInDatabase('schedules', ['id' => $scheduleOne->id, 'who_object' => Company::class, 'who_id' => $companyOne->id]);
     $this->seeInDatabase('schedules', ['id' => $scheduleTwo->id, 'who_object' => Company::class, 'who_id' => $companyTwo->id]);
 }
Exemple #4
0
 public function getDayNameAttribute()
 {
     $scheduleRepository = new ScheduleRepository();
     $week_days = $scheduleRepository->week_days();
     return $week_days[$this->attributes['week_day']];
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \App\Company $company
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, Company $company)
 {
     $this->authorize('update-company', $company);
     $this->validate($request, ['name' => 'required|max:255', 'licence_expire_at' => 'date_format:Y-m-d']);
     $company->name = $request->name;
     if ($request->licence_expire_at != '') {
         $company->licence_expire_at = $request->licence_expire_at;
         $company->is_suspended = false;
     }
     $company->save();
     // update schedules for SendReminderEmail(s)
     if (isset($company->licence_expire_at)) {
         $lrc = new LicenceReminderCalculator();
         $scheduleRepository = new ScheduleRepository();
         $scheduleRepository->removeAllForObject($company);
         // send reminders emails on configured days before expiration date
         $reminders = $scheduleRepository->addSendReminderEmail($company, $lrc);
         // suspend company on expiration date
         $suspensions = $scheduleRepository->addSuspendCompany($company);
         // send suspension emails on expiration date
         $suspensionEmails = $scheduleRepository->addSendSuspensionEmail($company);
         // send approval email now
         $approvalEmail = new ActionCommandSendApprovalEmailCommand($company->id);
         $approvalEmail->execute();
     }
     return redirect('/companies');
 }
Exemple #6
0
 public function scheduleInfo(Skill $skill)
 {
     $schedules = $skill->schedules()->get();
     $scheduleRepository = new ScheduleRepository();
     $amountRepository = new AmountRepository();
     $serviceRepository = new ServiceRepository();
     $amount_types = $amountRepository->type();
     $amount_per_units = $amountRepository->per_units();
     $amount_units = $amountRepository->units();
     $week_days = $scheduleRepository->week_days();
     $services_list = $serviceRepository->all();
     $amounts = $skill->amounts()->get();
     $areas = $skill->areas()->get();
     $galleries = $skill->galleries()->get();
     $services = $skill->services()->get();
     $provinces = Province::where('parent_id', null)->lists('name', 'id');
     $cities = Province::where('parent_id', null)->firstOrFail()->getDescendants()->lists('name', 'id');
     return view('profile.newSkill', compact('skill', 'schedules', 'week_days', 'amounts', 'amount_types', 'amount_per_units', 'amount_units', 'areas', 'provinces', 'galleries', 'cities', 'services', 'services_list'))->with(['title' => 'ثبت مهارت جدید', 'new_skill' => 0, 'edit_skill' => 1, 'step' => 3, 'hasEdit' => 1]);
 }