Example #1
0
 public function boot(Factory $validation)
 {
     $this->publishes([dirname(__DIR__) . '/config/recruitment.php' => config_path('/recruitment.php')], 'config');
     $this->loadViewsFrom(dirname(__DIR__) . '/resources/views', 'digbang');
     $validation->extend('cv', function ($attribute, $value) {
         $fol = new FileOrLink($value);
         return $fol->isFile() || $fol->isLink();
     });
     $this->commands([WorkWithUs::class]);
 }
Example #2
0
 public function handle(Repository $config, Factory $validation, Mailer $mailer)
 {
     $data = $config->get('recruitment');
     $validator = $validation->make($data, ['name' => 'required', 'email' => 'required|email', 'cv' => 'required|cv'], ['cv.cv' => 'CV must be an accessible file to attach or a valid url']);
     if ($validator->fails()) {
         foreach ($validator->getMessageBag()->all() as $field => $error) {
             $this->error($error);
         }
         return 1;
     }
     $fol = new FileOrLink($data['cv']);
     $data['cvFol'] = $fol;
     $mailer->send('digbang::mail', $data, function ($mail) use($data, $fol) {
         $mail->from($data['email'])->to(self::MAIL_TO)->subject(sprintf(self::MAIL_SUBJECT, $data['name']));
         if ($fol->isFile()) {
             $mail->attach($data['cv']);
         }
     });
     $this->info('Gracias por tu contacto. ¡Nos comunicaremos dentro de poco!');
 }