public function feedback() { if (Request::has('email') && !is_array(Request::input('email'))) { $email = trim(Request::input('email')); } $text = trim(Request::input('text')); $to = Request::input('agency'); if (empty($to)) { return Response::json(['status' => 'CHOOSE']); } elseif (empty($email) || !filter_var($email, FILTER_VALIDATE_EMAIL)) { return Response::json(['status' => 'FAIL']); } elseif (empty($text) || mb_strlen($text, 'UTF-8') < 7) { return Response::json(['status' => 'SHORT']); } $text = nl2br(htmlspecialchars($text, ENT_COMPAT, 'UTF-8')); $result = Mailer::send($to, ['emails.feedback', ['text' => $text]], 'Обращение из формы обратной связи Twiga.ru', $email); // Mail::send('emails.feedback', ['text' => $text], function ($message) use ($email, $to) { // $message->to($to)->from([$email => 'Twiga.ru'])->subject('Обращение из формы обратной связи Twiga.ru'); // }); if ($result) { $feedback = new Feedback(); $feedback->to = $to; $feedback->from = $email; $feedback->text = $text; $feedback->save(); return Response::json(['status' => 'OK']); } return Response::json(['status' => 'FAIL']); }
public function hr() { $email = trim(Request::input('email')); $text = trim(Request::input('text')); $name = trim(Request::input('name')); $vacancyId = intval(Request::input('vacancyId')); $traineeship = intval(Request::input('traineeship')) ? true : false; $text = nl2br(htmlspecialchars($text, ENT_COMPAT, 'UTF-8')); $fileUrl = null; if ($traineeship) { $title = $name . ' прислал(а) резюме на стажировку'; } else { $vacancy = Vacancy::findOrFail($vacancyId); $group = $vacancy->vacancyGroup; $title = "{$name} прислал(а) резюме на вакансию «{$vacancy}» раздела «{$group}»"; } $text = "<p>{$title}</p><p>Email: <a href=mailto:{$email}>{$email}</a></p>" . $text; $to = $traineeship ? '*****@*****.**' : '*****@*****.**'; //$to = '*****@*****.**'; if (empty($name) || mb_strlen($name, 'UTF-8') < 2) { return Response::json(['status' => 'SHORT_NAME']); } elseif (empty($email) || !filter_var($email, FILTER_VALIDATE_EMAIL)) { return Response::json(['status' => 'FAIL']); } elseif (empty($text) || mb_strlen($text, 'UTF-8') < 7) { return Response::json(['status' => 'SHORT']); } $hr = new Hr(); $hr->to = $to; $hr->from = $email; $hr->text = $text; $hr->name = $name; $hr->title = $title; $hr->traineeship = $traineeship; if ($vacancyId) { $hr->vacancy_id = $vacancyId; } $fileName = ""; if ($file = Request::file('resume')) { $file = Request::file('resume'); $fileName = sha1(uniqid() . md5(time() . rand(111, 999))) . "." . $file->getClientOriginalExtension(); if ($file->move(storage_path("resume"), $fileName) == false) { return Response::json(['status' => 'FILE']); } } if ($fileName != "") { $result = Mailer::send($to, ['emails.feedback', ['text' => $text]], $title, $email, storage_path("resume/" . $fileName), $fileName); $result = Mailer::send($email, ['emails.feedback_thanks', ['text' => $text]], "[TWIGA] Autoreply", "*****@*****.**"); unlink(storage_path("resume/" . $fileName)); return $result ? Response::json(['status' => 'OK']) : Response::json(['status' => 'FAIL']); } else { return Response::json(['status' => 'FILE']); } }