/**
  * Execute the job.
  *
  * @return void
  */
 public function handle(UserRepository $repository, Flash $flash)
 {
     $user = $repository->findUserByEmail($this->data['email']);
     if ($user) {
         $flash->error('Email already exists.');
         return null;
     }
     return $repository->registerUser($this->data);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store($tourId, Request $request, Flash $flash)
 {
     $photoIds = $request->input('photoIds') ? $request->input('photoIds') : null;
     if ($photoIds == null || count($photoIds) != 4) {
         $flash->error('Please select 4 photos for gallery.');
         return redirect()->back()->withInput();
     }
     $this->dispatchFrom(ManagePhotosJob::class, $request, compact('tourId'));
     return redirect()->route('tours.show', $tourId);
 }
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle(UserRepository $repository, Flash $flash)
 {
     $user = $repository->findUser($this->id);
     if ($user->email != $this->data['email']) {
         if ($repository->findUserByEmail($this->data['email'])) {
             $flash->error('Email already exists.');
             return null;
         }
     }
     return $repository->updateUser($this->id, $this->data);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store($tourId, Request $request, Flash $flash)
 {
     $countryIds = $request->input('countryIds') ? $request->input('countryIds') : null;
     $activityIds = $request->input('activityIds') ? $request->input('activityIds') : null;
     if (!$activityIds || !$countryIds) {
         $flash->error('Destinations and Activities are required.');
         return redirect()->back()->withInput();
     }
     $this->dispatchFrom(CreateTourRelationsJob::class, $request, compact('tourId'));
     return redirect()->route('photoManager', $tourId);
 }
 public function removeFile($filename, Flash $flash)
 {
     $file = "{$filename}.pdf";
     if (\Storage::exists($file)) {
         \Storage::delete($file);
         $flash->success('File has been deleted.');
     }
     return redirect()->back();
 }
 public function subscribe(SubscribeRequest $request, Flash $flash)
 {
     $this->dispatchFrom(SubscribeNewsLetterJob::class, $request);
     $flash->success('Thank you!');
     return redirect()->route('home');
 }