Commit 5fc27fa4abd33284123a24afbfa17f182be43ed8
1 parent
4ab406cc8c
Exists in
master
Отправка писем на почту, баг с картинками, удаление кнопки удаление
Showing 10 changed files with 188 additions and 21 deletions Side-by-side Diff
- app/Http/Controllers/MainController.php
- app/Http/Requests/AreasRequest.php
- app/Http/Requests/FooterFeedbackRequest.php
- app/Mail/SendMail.php
- resources/views/admin/area/form.blade.php
- resources/views/admin/houses/form.blade.php
- resources/views/complex.blade.php
- resources/views/emails/main.blade.php
- resources/views/mapsobj.blade.php
- routes/web.php
app/Http/Controllers/MainController.php
... | ... | @@ -5,6 +5,7 @@ namespace App\Http\Controllers; |
5 | 5 | use App\Classes\SortData; |
6 | 6 | use App\Http\Requests\EmailRequest; |
7 | 7 | use App\Http\Requests\FooterFeedbackRequest; |
8 | +use App\Mail\SendMail; | |
8 | 9 | use App\Models\Area; |
9 | 10 | use App\Models\Contact; |
10 | 11 | use App\Models\format_area; |
... | ... | @@ -22,6 +23,7 @@ use Illuminate\Support\Facades\Mail; |
22 | 23 | use PhpParser\Node\Stmt\Switch_; |
23 | 24 | use Illuminate\Support\Facades\Response; |
24 | 25 | use App\Classes\FilterData; |
26 | +//use App\Mail\SendMail; | |
25 | 27 | |
26 | 28 | class MainController extends Controller |
27 | 29 | { |
... | ... | @@ -153,6 +155,14 @@ class MainController extends Controller |
153 | 155 | return view('about', compact('news', 'partners')); |
154 | 156 | } |
155 | 157 | |
158 | + public function send_mail() { | |
159 | + $toEmail = "integralal@mail.ru";//$RentTorg[0]->email; | |
160 | + $message = "Тест сообщения, проверка связи!"; | |
161 | + $mm = new SendMail($message); | |
162 | + $d = Mail::to($toEmail)->send(new SendMail($message)); | |
163 | + dd($d); | |
164 | + } | |
165 | + | |
156 | 166 | /* |
157 | 167 | * Форма обратной связи внизу сайта |
158 | 168 | */ |
... | ... | @@ -163,17 +173,36 @@ class MainController extends Controller |
163 | 173 | $MailBD->from = $request->TelephoneUser; |
164 | 174 | $MailBD->subject = "Пользователь <".$request->NameUser.">"; |
165 | 175 | $MailBD->form = 'Форма в футере'; |
166 | - $MailBD->text = "От пользователя: ".$request->NameUser.". Заявка на лучшие предложения. Сообщение: ".$request->TextUser; | |
176 | + $message = "От пользователя: ".$request->NameUser.". Телефон: ".$request->TelephoneUser.". Заявка на лучшие предложения. Сообщение: ".$request->TextUser; | |
177 | + $MailBD->text = $message; | |
167 | 178 | $MailBD->save(); |
168 | 179 | |
180 | + $toEmail = $RentTorg[0]->email; | |
181 | + $mm = new SendMail($message); | |
182 | + $d = Mail::to($toEmail)->send(new SendMail($message)); | |
183 | + | |
184 | + //$toEmail = "integralal@mail.ru";//$RentTorg[0]->email; | |
185 | + /*$email = $RentTorg[0]->email; | |
186 | + $sender = "alarionov@nologostudio.ru"; | |
187 | + | |
188 | + $headers = "From: $sender" . "\r\n" . | |
189 | + "Reply-To: $sender" . "\r\n" . | |
190 | + "X-Mailer: PHP/" . phpversion(); | |
191 | + mail($email, "От сайта Рентторг", $message, $headers); | |
192 | +*/ | |
193 | + //$mm = new SendMail($message); | |
194 | + //Mail::to($toEmail)->send($mm); | |
195 | + | |
169 | 196 | //return true; |
170 | - /* | |
197 | + /* | |
171 | 198 | Mail::send('emails.feedback', ['user' => $user], |
172 | 199 | function ($message) use ($user) { |
173 | 200 | $message->from('sender@gmail.com', 'Sender'); |
174 | 201 | $message->to($user->email, $user->name)->subject('Test message'); |
175 | 202 | }); |
176 | 203 | */ |
204 | + | |
205 | + | |
177 | 206 | } |
178 | 207 | |
179 | 208 | /* |
... | ... | @@ -186,8 +215,22 @@ class MainController extends Controller |
186 | 215 | $MailBD->from = $request->TelephoneUser; |
187 | 216 | $MailBD->subject = "Пользователь <".$request->NameUser.">"; |
188 | 217 | $MailBD->form = 'Форма в заголовке сайта'; |
189 | - $MailBD->text = "От пользователя: ".$request->NameUser." Сообщение: Заказываю обратный звонок"; | |
218 | + $message = "От пользователя: ".$request->NameUser.". Телефон: ".$request->TelephoneUser.". Сообщение: Заказываю обратный звонок"; | |
219 | + $MailBD->text = $message; | |
190 | 220 | $MailBD->save(); |
221 | + | |
222 | + $toEmail = $RentTorg[0]->email; | |
223 | + $mm = new SendMail($message); | |
224 | + $d = Mail::to($toEmail)->send(new SendMail($message)); | |
225 | + | |
226 | + /*$email = $RentTorg[0]->email; | |
227 | + $sender = "alarionov@nologostudio.ru"; | |
228 | + | |
229 | + $headers = "From: $sender" . "\r\n" . | |
230 | + "Reply-To: $sender" . "\r\n" . | |
231 | + "X-Mailer: PHP/" . phpversion(); | |
232 | + mail($email, "От сайта Рентторг", $message, $headers); | |
233 | + */ | |
191 | 234 | } |
192 | 235 | |
193 | 236 | /* |
... | ... | @@ -200,9 +243,21 @@ class MainController extends Controller |
200 | 243 | $MailBD->from = $request->TelephoneUser; |
201 | 244 | $MailBD->subject = "Пользователь <".$request->NameUser.">"; |
202 | 245 | $MailBD->form = 'Форма записи на просмотр'; |
203 | - $MailBD->text = "От пользователя: ".$request->NameUser." Сообщение: Заказываю просмотр офиса"; | |
204 | - $MailBD->text .= "Адрес офиса-объекта: ".url()->previous()." "; | |
246 | + $message = "От пользователя: ".$request->NameUser.". Телефон: ".$request->TelephoneUser.". Сообщение: Заказываю просмотр офиса"; | |
247 | + $message.= "Адрес офиса-объекта: ".url()->previous()." "; | |
248 | + $MailBD->text = $message; | |
205 | 249 | $MailBD->save(); |
250 | + | |
251 | + $toEmail = $RentTorg[0]->email; | |
252 | + $d = Mail::to($toEmail)->send(new SendMail($message)); | |
253 | + | |
254 | + /*$email = $RentTorg[0]->email; | |
255 | + $sender = "alarionov@nologostudio.ru"; | |
256 | + | |
257 | + $headers = "From: $sender" . "\r\n" . | |
258 | + "Reply-To: $sender" . "\r\n" . | |
259 | + "X-Mailer: PHP/" . phpversion(); | |
260 | + mail($email, "От сайта Рентторг", $message, $headers);*/ | |
206 | 261 | } |
207 | 262 | |
208 | 263 | /* |
... | ... | @@ -215,8 +270,22 @@ class MainController extends Controller |
215 | 270 | $MailBD->from = $request->TelephoneUser; |
216 | 271 | $MailBD->subject = "Пользователь <".$request->NameUser."> Компания <".$request->NameCompany.">"; |
217 | 272 | $MailBD->form = 'Форма на странице "Контакты"'; |
218 | - $MailBD->text = "От пользователя: ".$request->NameUser."Телефон: ".$request->TelephoneUser." Почта: <".$request->EmailUser."> Сообщение:".$request->TextUser; | |
273 | + $message = "От пользователя: ".$request->NameUser.". Компания <".$request->NameCompany.">. Телефон: ".$request->TelephoneUser." Почта: <".$request->EmailUser."> Сообщение:".$request->TextUser; | |
274 | + $MailBD->text = $message; | |
219 | 275 | $MailBD->save(); |
276 | + | |
277 | + $toEmail = $RentTorg[0]->email; | |
278 | + $d = Mail::to($toEmail)->send(new SendMail($message)); | |
279 | + | |
280 | + /* | |
281 | + $email = $RentTorg[0]->email; | |
282 | + $sender = "alarionov@nologostudio.ru"; | |
283 | + | |
284 | + $headers = "From: $sender" . "\r\n" . | |
285 | + "Reply-To: $sender" . "\r\n" . | |
286 | + "X-Mailer: PHP/" . phpversion(); | |
287 | + mail($email, "От сайта Рентторг", $message, $headers); | |
288 | + */ | |
220 | 289 | } |
221 | 290 | /* |
222 | 291 | * Форма обратной связи по емайлу |
... | ... | @@ -228,8 +297,22 @@ class MainController extends Controller |
228 | 297 | $MailBD->from = $request->EmailUser; |
229 | 298 | $MailBD->subject = "Пользователь <".$request->EmailUser.">"; |
230 | 299 | $MailBD->form = 'Форма обратной связи по Email'; |
231 | - $MailBD->text = "От почты: ".$request->EmailUser." Сообщение: Отправить на данную почту предложения RentTorg"; | |
300 | + $message = "От почты: ".$request->EmailUser.". Сообщение: Отправить на данную почту предложения RentTorg"; | |
301 | + $MailBD->text = $message; | |
232 | 302 | $MailBD->save(); |
303 | + | |
304 | + $toEmail = $RentTorg[0]->email; | |
305 | + $d = Mail::to($toEmail)->send(new SendMail($message)); | |
306 | + | |
307 | + /* | |
308 | + $email = $RentTorg[0]->email; | |
309 | + $sender = "alarionov@nologostudio.ru"; | |
310 | + | |
311 | + $headers = "From: $sender" . "\r\n" . | |
312 | + "Reply-To: $sender" . "\r\n" . | |
313 | + "X-Mailer: PHP/" . phpversion(); | |
314 | + mail($email, "От сайта Рентторг", $message, $headers); | |
315 | + */ | |
233 | 316 | //dd('Email form'); |
234 | 317 | return redirect()->route('index'); |
235 | 318 | } |
app/Http/Requests/AreasRequest.php
... | ... | @@ -26,14 +26,25 @@ class AreasRequest extends FormRequest |
26 | 26 | return [ |
27 | 27 | 'name_area' => 'required|min:3|max:255', |
28 | 28 | 'description' => 'required|min:5', |
29 | + 'foto_main' => [ | |
30 | + 'mimes:jpeg,jpg,png', | |
31 | + 'max:10000' | |
32 | + ], | |
29 | 33 | ]; |
30 | 34 | } |
31 | 35 | |
32 | 36 | public function messages() { |
33 | 37 | return [ |
34 | 38 | 'required' => 'Поле :attribute обязательно для ввода', |
35 | - 'min' => 'Поле :attribute должно иметь минимум :min символов', | |
36 | - 'max' => 'Поле :attribute должно содержать не более :max символов' | |
39 | + 'min' => [ | |
40 | + 'string' => 'Поле «:attribute» должно быть не меньше :min символов', | |
41 | + 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' | |
42 | + ], | |
43 | + 'max' => [ | |
44 | + 'string' => 'Поле «:attribute» должно быть не больше :max символов', | |
45 | + 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' | |
46 | + ], | |
47 | + | |
37 | 48 | ]; |
38 | 49 | } |
39 | 50 |
app/Http/Requests/FooterFeedbackRequest.php
app/Mail/SendMail.php
... | ... | @@ -0,0 +1,65 @@ |
1 | +<?php | |
2 | + | |
3 | +namespace App\Mail; | |
4 | + | |
5 | +use Illuminate\Bus\Queueable; | |
6 | +use Illuminate\Contracts\Queue\ShouldQueue; | |
7 | +use Illuminate\Mail\Mailable; | |
8 | +use Illuminate\Mail\Mailables\Content; | |
9 | +use Illuminate\Mail\Mailables\Envelope; | |
10 | +use Illuminate\Queue\SerializesModels; | |
11 | + | |
12 | +class SendMail extends Mailable | |
13 | +{ | |
14 | + use Queueable, SerializesModels; | |
15 | + | |
16 | + public $mess; | |
17 | + | |
18 | + /** | |
19 | + * Create a new message instance. | |
20 | + * | |
21 | + * @return void | |
22 | + */ | |
23 | + public function __construct($mess) | |
24 | + { | |
25 | + $this->mess = $mess; | |
26 | + } | |
27 | + | |
28 | + /** | |
29 | + * Get the message envelope. | |
30 | + * | |
31 | + * @return \Illuminate\Mail\Mailables\Envelope | |
32 | + */ | |
33 | + public function envelope() | |
34 | + { | |
35 | + return new Envelope( | |
36 | + subject: 'Send Mail', | |
37 | + ); | |
38 | + } | |
39 | + | |
40 | + /** | |
41 | + * Get the message content definition. | |
42 | + * | |
43 | + * @return \Illuminate\Mail\Mailables\Content | |
44 | + */ | |
45 | + public function content() | |
46 | + { | |
47 | + return new Content( | |
48 | + view: 'emails.main', | |
49 | + ); | |
50 | + } | |
51 | + | |
52 | + /** | |
53 | + * Get the attachments for the message. | |
54 | + * | |
55 | + * @return array | |
56 | + */ | |
57 | + public function attachments() | |
58 | + { | |
59 | + return []; | |
60 | + } | |
61 | + | |
62 | + public function build() { | |
63 | + return $this->view('emails.main', ['mess' => $this->mess]); | |
64 | + } | |
65 | +} |
resources/views/admin/area/form.blade.php
... | ... | @@ -33,10 +33,10 @@ |
33 | 33 | @isset($area->foto_main) |
34 | 34 | <div class="form-group form-check"> |
35 | 35 | <img src="/storage/app/public/<?=$area->foto_main;//=asset(Storage::url($area->foto_main))?>" width="100px"/> |
36 | - <input type="checkbox" class="form-check-input" name="remove" id="remove"> | |
36 | + <!--<input type="checkbox" class="form-check-input" name="remove" id="remove"> | |
37 | 37 | <label class="form-check-label" for="remove"> |
38 | 38 | Удалить загруженное изображение |
39 | - </label> | |
39 | + </label>--> | |
40 | 40 | </div> |
41 | 41 | @endisset |
42 | 42 | <br><br> |
resources/views/admin/houses/form.blade.php
... | ... | @@ -114,10 +114,10 @@ |
114 | 114 | @isset($house->foto_main) |
115 | 115 | <div class="form-group form-check"> |
116 | 116 | <img src="/storage/app/public/<?=$house->foto_main;//=asset(Storage::url($house->foto_main))?>" width="100px"/> |
117 | - <input type="checkbox" class="form-check-input" name="remove" id="remove"> | |
117 | + <!--<input type="checkbox" class="form-check-input" name="remove" id="remove"> | |
118 | 118 | <label class="form-check-label" for="remove"> |
119 | 119 | Удалить загруженное изображение |
120 | - </label> | |
120 | + </label>--> | |
121 | 121 | </div> |
122 | 122 | @endisset |
123 | 123 | <br> |
... | ... | @@ -245,7 +245,7 @@ |
245 | 245 | |
246 | 246 | @isset($house->present) |
247 | 247 | <div class="form-group form-check"> |
248 | - <a href="<?=asset(Storage::url($house->floor_plan))?>">Презентация</a> | |
248 | + <a href="/storage/app/public/<?=$house->present//asset(Storage::url($house->floor_plan))?>">Презентация</a> | |
249 | 249 | </div> |
250 | 250 | @endisset |
251 | 251 | <br><br> |
resources/views/complex.blade.php
... | ... | @@ -125,8 +125,8 @@ |
125 | 125 | <? if (!empty($area->foto_main)) {?> |
126 | 126 | <div class="swiper-slide"> |
127 | 127 | <div class="intro-item"> |
128 | - <div class="intro-item__img"><img src="{{ asset(Storage::url($area->foto_main)) }}" alt=""></div> | |
129 | - <a class="intro-item__btn js_intro_item_btn" href="{{ asset(Storage::url($area->foto_main)) }}" data-caption="{{ $area->name_area }}"> | |
128 | + <div class="intro-item__img"><img src="/storage/app/public/<?=$area->foto_main; //asset(Storage::url($area->foto_main)) ?>" alt=""></div> | |
129 | + <a class="intro-item__btn js_intro_item_btn" href="/storage/app/public/<?=$area->foto_main; //asset(Storage::url($area->foto_main)) ?>" data-caption="{{ $area->name_area }}"> | |
130 | 130 | <svg width="16" height="16"> |
131 | 131 | <use xlink:href="{{ asset('images/sprite.svg#intro-item-btn') }}"></use> |
132 | 132 | </svg></a> |
... | ... | @@ -138,8 +138,8 @@ |
138 | 138 | @foreach($area->fotos as $img) |
139 | 139 | <div class="swiper-slide"> |
140 | 140 | <div class="intro-item"> |
141 | - <div class="intro-item__img"><img src="{{ asset(Storage::url($img->foto)) }}" alt=""></div> | |
142 | - <a class="intro-item__btn js_intro_item_btn" href="{{ asset(Storage::url($img->foto)) }}" data-caption="Фото {{ $i }}"> | |
141 | + <div class="intro-item__img"><img src="/storage/app/public/<?=$img->foto; //asset(Storage::url($img->foto)) ?>" alt=""></div> | |
142 | + <a class="intro-item__btn js_intro_item_btn" href="/storage/app/public/<?=$img->foto; //asset(Storage::url($img->foto)) ?>" data-caption="Фото {{ $i }}"> | |
143 | 143 | <svg width="16" height="16"> |
144 | 144 | <use xlink:href="{{ asset('images/sprite.svg#intro-item-btn') }}"></use> |
145 | 145 | </svg></a> |
resources/views/emails/main.blade.php
resources/views/mapsobj.blade.php
... | ... | @@ -205,7 +205,9 @@ |
205 | 205 | @if ($houses->count()) |
206 | 206 | @foreach ($houses as $house) |
207 | 207 | <div class="card-news"> |
208 | - <div class="card-news__top"><img src="{{ asset(Storage::url($house->foto_main)) }}" alt="Превью по {{$house->title}}" loading="lazy"> | |
208 | + <div class="card-news__top"> | |
209 | + <img src="/storage/app/public/<?=$house->foto_main;//=asset(Storage::url($house->foto_main)) ?>" alt="Превью по {{$house->title}}" loading="lazy"> | |
210 | + | |
209 | 211 | <div class="card-news__date"><span>{{ $house->title }}</span><span></span></div> |
210 | 212 | </div> |
211 | 213 | <div class="card-news__cnt"> |
... | ... | @@ -240,7 +242,7 @@ |
240 | 242 | @if ($areas->count()) |
241 | 243 | @foreach ($areas as $area) |
242 | 244 | <div class="card-news"> |
243 | - <div class="card-news__top"><img src="{{ asset(Storage::url($area->foto_main)) }}" alt="Превью по {{$area->name_area}}" loading="lazy"> | |
245 | + <div class="card-news__top"><img src="/storage/app/public/<?=$area->foto_main; //asset(Storage::url($area->foto_main))?>" alt="Превью по {{$area->name_area}}" loading="lazy"> | |
244 | 246 | <div class="card-news__date"><span>{{ $area->name_area }}</span><span></span></div> |
245 | 247 | </div> |
246 | 248 | <div class="card-news__cnt"> |
routes/web.php
... | ... | @@ -25,6 +25,9 @@ use App\Http\Controllers\Admin\MessageAreaController; |
25 | 25 | | |
26 | 26 | */ |
27 | 27 | |
28 | +//тест отправка почты | |
29 | +Route::get('email', [MainController::class, 'send_mail'])->name('send.mail'); | |
30 | + | |
28 | 31 | //Главная страница |
29 | 32 | Route::get('/',[MainController::class, 'index'])->name('index'); |
30 | 33 |