예제 #1
0
 /**
  * @author EB
  * @param Request $request
  * @param Location $location
  * @return \Illuminate\Http\RedirectResponse|Redirect
  * @throws \Exception
  */
 private function handleApplicationRequest(Request $request, Location $location)
 {
     if ($request->has('assisted')) {
         try {
             $application = $this->createAssistedApplication($location, $request);
         } catch (\Exception $e) {
             return redirect('/locations/' . $location->id . '/no-finance');
         }
         if (is_null($application->ext_user)) {
             $this->createProfilePersonal($request, $location, $application);
             return redirect('/locations/' . $location->id . '/applications/' . $application->id . '/profile');
         }
         $this->applicationSynchronisationService->synchroniseApplication($application->id);
         return $this->redirectWithSuccessMessage('/installations/' . $location->installation->id . '/applications/' . $application->id, 'Application successfully created. You can action on this in the `Application / Resume Link` section below');
     }
     $application = $this->createApplication($location, $request);
     if ($request->has('email')) {
         return redirect('/installations/' . $location->installation->id . '/applications/' . $application->id . '/email');
     }
     ApplicationEventHelper::addEvent($application, ApplicationEvent::TYPE_RESUME_INSTORE, Auth::user());
     return redirect($application->ext_resume_url);
 }
 /**
  * @author WN
  * @param ApplicationEntity $applicationEntity
  * @param int $installationId
  * @param int|null $requester
  * @param null $location
  * @return Application
  * @throws Exception
  */
 private function createNewLocal(ApplicationEntity $applicationEntity, $installationId, $requester = null, $location = null)
 {
     $app = new Application();
     $app->installation_id = $installationId;
     $app->ext_id = $applicationEntity->getId();
     $app->user_id = $requester;
     $app->location_id = $location;
     $mapApplicationHelper = new MapApplicationHelper();
     $mapApplicationHelper->mapApplication($applicationEntity, $app);
     if ($app->save()) {
         ApplicationEventHelper::addEvent($app, ApplicationEvent::TYPE_NOTIFICATION_INITIALISED, Auth::user());
         return $app;
     }
     throw new Exception('Problem saving Application');
 }
예제 #3
0
 /**
  * @author EB
  * @param int $location
  * @param int $application
  * @return \Illuminate\Http\RedirectResponse
  * @throws RedirectException
  */
 public function finishApplication($location, $application)
 {
     try {
         /** @var Location $location */
         $location = Location::findOrFail($location);
         $application = $this->fetchApplicationById($application, $location->installation->id);
         ApplicationEvent\ApplicationEventHelper::addEvent($application, ApplicationEvent::TYPE_RESUME_LINK);
     } catch (\Exception $e) {
         throw $this->redirectWithException('installations/' . $location->installation->id . '/applications', 'Unable to complete the application: ' . $e->getMessage(), $e);
     }
     return $this->redirectWithSuccessMessage('installations/' . $location->installation->id . '/applications/' . $application->id, 'Successfully created an application');
 }