From 5fc27fa4abd33284123a24afbfa17f182be43ed8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BD=D0=B4=D1=80=D0=B5=D0=B9=20=20=D0=9B=D0=B0=D1=80?= =?UTF-8?q?=D0=B8=D0=BE=D0=BD=D0=BE=D0=B2?= Date: Thu, 30 Mar 2023 13:24:52 +0700 Subject: [PATCH] =?UTF-8?q?=D0=9E=D1=82=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B0=20?= =?UTF-8?q?=D0=BF=D0=B8=D1=81=D0=B5=D0=BC=20=D0=BD=D0=B0=20=D0=BF=D0=BE=D1=87?= =?UTF-8?q?=D1=82=D1=83,=20=D0=B1=D0=B0=D0=B3=20=D1=81=20=D0=BA=D0=B0=D1=80=D1?= =?UTF-8?q?=82=D0=B8=D0=BD=D0=BA=D0=B0=D0=BC=D0=B8,=20=D1=83=D0=B4=D0=B0=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BA=D0=BD=D0=BE=D0=BF=D0=BA=D0=B8=20?= =?UTF-8?q?=D1=83=D0=B4=D0=B0=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/MainController.php | 97 +++++++++++++++++++++++++-- app/Http/Requests/AreasRequest.php | 15 ++++- app/Http/Requests/FooterFeedbackRequest.php | 2 +- app/Mail/SendMail.php | 65 ++++++++++++++++++ resources/views/admin/area/form.blade.php | 4 +- resources/views/admin/houses/form.blade.php | 6 +- resources/views/complex.blade.php | 8 +-- resources/views/emails/main.blade.php | 3 + resources/views/mapsobj.blade.php | 6 +- routes/web.php | 3 + 10 files changed, 188 insertions(+), 21 deletions(-) create mode 100644 app/Mail/SendMail.php create mode 100644 resources/views/emails/main.blade.php diff --git a/app/Http/Controllers/MainController.php b/app/Http/Controllers/MainController.php index f29439e..59143ed 100644 --- a/app/Http/Controllers/MainController.php +++ b/app/Http/Controllers/MainController.php @@ -5,6 +5,7 @@ namespace App\Http\Controllers; use App\Classes\SortData; use App\Http\Requests\EmailRequest; use App\Http\Requests\FooterFeedbackRequest; +use App\Mail\SendMail; use App\Models\Area; use App\Models\Contact; use App\Models\format_area; @@ -22,6 +23,7 @@ use Illuminate\Support\Facades\Mail; use PhpParser\Node\Stmt\Switch_; use Illuminate\Support\Facades\Response; use App\Classes\FilterData; +//use App\Mail\SendMail; class MainController extends Controller { @@ -153,6 +155,14 @@ class MainController extends Controller return view('about', compact('news', 'partners')); } + public function send_mail() { + $toEmail = "integralal@mail.ru";//$RentTorg[0]->email; + $message = "Тест сообщения, проверка связи!"; + $mm = new SendMail($message); + $d = Mail::to($toEmail)->send(new SendMail($message)); + dd($d); + } + /* * Форма обратной связи внизу сайта */ @@ -163,17 +173,36 @@ class MainController extends Controller $MailBD->from = $request->TelephoneUser; $MailBD->subject = "Пользователь <".$request->NameUser.">"; $MailBD->form = 'Форма в футере'; - $MailBD->text = "От пользователя: ".$request->NameUser.". Заявка на лучшие предложения. Сообщение: ".$request->TextUser; + $message = "От пользователя: ".$request->NameUser.". Телефон: ".$request->TelephoneUser.". Заявка на лучшие предложения. Сообщение: ".$request->TextUser; + $MailBD->text = $message; $MailBD->save(); + $toEmail = $RentTorg[0]->email; + $mm = new SendMail($message); + $d = Mail::to($toEmail)->send(new SendMail($message)); + + //$toEmail = "integralal@mail.ru";//$RentTorg[0]->email; + /*$email = $RentTorg[0]->email; + $sender = "alarionov@nologostudio.ru"; + + $headers = "From: $sender" . "\r\n" . + "Reply-To: $sender" . "\r\n" . + "X-Mailer: PHP/" . phpversion(); + mail($email, "От сайта Рентторг", $message, $headers); +*/ + //$mm = new SendMail($message); + //Mail::to($toEmail)->send($mm); + //return true; - /* + /* Mail::send('emails.feedback', ['user' => $user], function ($message) use ($user) { $message->from('sender@gmail.com', 'Sender'); $message->to($user->email, $user->name)->subject('Test message'); }); */ + + } /* @@ -186,8 +215,22 @@ class MainController extends Controller $MailBD->from = $request->TelephoneUser; $MailBD->subject = "Пользователь <".$request->NameUser.">"; $MailBD->form = 'Форма в заголовке сайта'; - $MailBD->text = "От пользователя: ".$request->NameUser." Сообщение: Заказываю обратный звонок"; + $message = "От пользователя: ".$request->NameUser.". Телефон: ".$request->TelephoneUser.". Сообщение: Заказываю обратный звонок"; + $MailBD->text = $message; $MailBD->save(); + + $toEmail = $RentTorg[0]->email; + $mm = new SendMail($message); + $d = Mail::to($toEmail)->send(new SendMail($message)); + + /*$email = $RentTorg[0]->email; + $sender = "alarionov@nologostudio.ru"; + + $headers = "From: $sender" . "\r\n" . + "Reply-To: $sender" . "\r\n" . + "X-Mailer: PHP/" . phpversion(); + mail($email, "От сайта Рентторг", $message, $headers); + */ } /* @@ -200,9 +243,21 @@ class MainController extends Controller $MailBD->from = $request->TelephoneUser; $MailBD->subject = "Пользователь <".$request->NameUser.">"; $MailBD->form = 'Форма записи на просмотр'; - $MailBD->text = "От пользователя: ".$request->NameUser." Сообщение: Заказываю просмотр офиса"; - $MailBD->text .= "Адрес офиса-объекта: ".url()->previous()." "; + $message = "От пользователя: ".$request->NameUser.". Телефон: ".$request->TelephoneUser.". Сообщение: Заказываю просмотр офиса"; + $message.= "Адрес офиса-объекта: ".url()->previous()." "; + $MailBD->text = $message; $MailBD->save(); + + $toEmail = $RentTorg[0]->email; + $d = Mail::to($toEmail)->send(new SendMail($message)); + + /*$email = $RentTorg[0]->email; + $sender = "alarionov@nologostudio.ru"; + + $headers = "From: $sender" . "\r\n" . + "Reply-To: $sender" . "\r\n" . + "X-Mailer: PHP/" . phpversion(); + mail($email, "От сайта Рентторг", $message, $headers);*/ } /* @@ -215,8 +270,22 @@ class MainController extends Controller $MailBD->from = $request->TelephoneUser; $MailBD->subject = "Пользователь <".$request->NameUser."> Компания <".$request->NameCompany.">"; $MailBD->form = 'Форма на странице "Контакты"'; - $MailBD->text = "От пользователя: ".$request->NameUser."Телефон: ".$request->TelephoneUser." Почта: <".$request->EmailUser."> Сообщение:".$request->TextUser; + $message = "От пользователя: ".$request->NameUser.". Компания <".$request->NameCompany.">. Телефон: ".$request->TelephoneUser." Почта: <".$request->EmailUser."> Сообщение:".$request->TextUser; + $MailBD->text = $message; $MailBD->save(); + + $toEmail = $RentTorg[0]->email; + $d = Mail::to($toEmail)->send(new SendMail($message)); + + /* + $email = $RentTorg[0]->email; + $sender = "alarionov@nologostudio.ru"; + + $headers = "From: $sender" . "\r\n" . + "Reply-To: $sender" . "\r\n" . + "X-Mailer: PHP/" . phpversion(); + mail($email, "От сайта Рентторг", $message, $headers); + */ } /* * Форма обратной связи по емайлу @@ -228,8 +297,22 @@ class MainController extends Controller $MailBD->from = $request->EmailUser; $MailBD->subject = "Пользователь <".$request->EmailUser.">"; $MailBD->form = 'Форма обратной связи по Email'; - $MailBD->text = "От почты: ".$request->EmailUser." Сообщение: Отправить на данную почту предложения RentTorg"; + $message = "От почты: ".$request->EmailUser.". Сообщение: Отправить на данную почту предложения RentTorg"; + $MailBD->text = $message; $MailBD->save(); + + $toEmail = $RentTorg[0]->email; + $d = Mail::to($toEmail)->send(new SendMail($message)); + + /* + $email = $RentTorg[0]->email; + $sender = "alarionov@nologostudio.ru"; + + $headers = "From: $sender" . "\r\n" . + "Reply-To: $sender" . "\r\n" . + "X-Mailer: PHP/" . phpversion(); + mail($email, "От сайта Рентторг", $message, $headers); + */ //dd('Email form'); return redirect()->route('index'); } diff --git a/app/Http/Requests/AreasRequest.php b/app/Http/Requests/AreasRequest.php index ed31508..216d306 100644 --- a/app/Http/Requests/AreasRequest.php +++ b/app/Http/Requests/AreasRequest.php @@ -26,14 +26,25 @@ class AreasRequest extends FormRequest return [ 'name_area' => 'required|min:3|max:255', 'description' => 'required|min:5', + 'foto_main' => [ + 'mimes:jpeg,jpg,png', + 'max:10000' + ], ]; } public function messages() { return [ 'required' => 'Поле :attribute обязательно для ввода', - 'min' => 'Поле :attribute должно иметь минимум :min символов', - 'max' => 'Поле :attribute должно содержать не более :max символов' + 'min' => [ + 'string' => 'Поле «:attribute» должно быть не меньше :min символов', + 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' + ], + 'max' => [ + 'string' => 'Поле «:attribute» должно быть не больше :max символов', + 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' + ], + ]; } diff --git a/app/Http/Requests/FooterFeedbackRequest.php b/app/Http/Requests/FooterFeedbackRequest.php index e3f0188..8191d9c 100644 --- a/app/Http/Requests/FooterFeedbackRequest.php +++ b/app/Http/Requests/FooterFeedbackRequest.php @@ -27,7 +27,7 @@ class FooterFeedbackRequest extends FormRequest 'TelephoneUser' => [ 'required', 'min:6', - 'max:12', + 'max:15', ], ]; } diff --git a/app/Mail/SendMail.php b/app/Mail/SendMail.php new file mode 100644 index 0000000..56ff7f5 --- /dev/null +++ b/app/Mail/SendMail.php @@ -0,0 +1,65 @@ +mess = $mess; + } + + /** + * Get the message envelope. + * + * @return \Illuminate\Mail\Mailables\Envelope + */ + public function envelope() + { + return new Envelope( + subject: 'Send Mail', + ); + } + + /** + * Get the message content definition. + * + * @return \Illuminate\Mail\Mailables\Content + */ + public function content() + { + return new Content( + view: 'emails.main', + ); + } + + /** + * Get the attachments for the message. + * + * @return array + */ + public function attachments() + { + return []; + } + + public function build() { + return $this->view('emails.main', ['mess' => $this->mess]); + } +} diff --git a/resources/views/admin/area/form.blade.php b/resources/views/admin/area/form.blade.php index 3e4ba5a..c9ab46a 100644 --- a/resources/views/admin/area/form.blade.php +++ b/resources/views/admin/area/form.blade.php @@ -33,10 +33,10 @@ @isset($area->foto_main)
- +
@endisset

diff --git a/resources/views/admin/houses/form.blade.php b/resources/views/admin/houses/form.blade.php index c02d06a..2ef2777 100644 --- a/resources/views/admin/houses/form.blade.php +++ b/resources/views/admin/houses/form.blade.php @@ -114,10 +114,10 @@ @isset($house->foto_main)
- +
@endisset
@@ -245,7 +245,7 @@ @isset($house->present)
- Презентация + Презентация
@endisset

diff --git a/resources/views/complex.blade.php b/resources/views/complex.blade.php index ceed184..5afcbc9 100644 --- a/resources/views/complex.blade.php +++ b/resources/views/complex.blade.php @@ -125,8 +125,8 @@ foto_main)) {?>
-
- +
+
@@ -138,8 +138,8 @@ @foreach($area->fotos as $img)
-
- +
+
diff --git a/resources/views/emails/main.blade.php b/resources/views/emails/main.blade.php new file mode 100644 index 0000000..b11e51c --- /dev/null +++ b/resources/views/emails/main.blade.php @@ -0,0 +1,3 @@ +
+ {{ $mess }} +
diff --git a/resources/views/mapsobj.blade.php b/resources/views/mapsobj.blade.php index 975a7dc..8ff86a4 100644 --- a/resources/views/mapsobj.blade.php +++ b/resources/views/mapsobj.blade.php @@ -205,7 +205,9 @@ @if ($houses->count()) @foreach ($houses as $house)
-
Превью по {{$house->title}} +
+ Превью по {{$house->title}} +
{{ $house->title }}
@@ -240,7 +242,7 @@ @if ($areas->count()) @foreach ($areas as $area)
-
Превью по {{$area->name_area}} +
Превью по {{$area->name_area}}
{{ $area->name_area }}
diff --git a/routes/web.php b/routes/web.php index 4afe34d..abcbaa2 100644 --- a/routes/web.php +++ b/routes/web.php @@ -25,6 +25,9 @@ use App\Http\Controllers\Admin\MessageAreaController; | */ +//тест отправка почты +Route::get('email', [MainController::class, 'send_mail'])->name('send.mail'); + //Главная страница Route::get('/',[MainController::class, 'index'])->name('index'); -- 1.7.10.4