From a9da0bb95e8b9da4572bb40c5a7667d084fb1f69 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: Tue, 18 Apr 2023 21:01:38 +0700 Subject: [PATCH] =?UTF-8?q?Pdf-=D0=B3=D0=B5=D0=BD=D0=B5=D1=80=D0=B0=D1=82=D0?= =?UTF-8?q?=BE=D1=80=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 - app/Http/Controllers/MainController.php | 27 ++++++++++++++++++++++++++- public/storage/.gitignore | 2 ++ resources/views/house/pdf.blade.php | 13 +++++++++++-- resources/views/house/post.blade.php | 2 +- resources/views/layout/site.blade.php | 2 +- routes/web.php | 7 +++++++ 7 files changed, 48 insertions(+), 6 deletions(-) create mode 100644 public/storage/.gitignore diff --git a/.gitignore b/.gitignore index f0d10af..e46f3cf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,6 @@ /node_modules /public/build /public/hot -/public/storage /storage/*.key /vendor .env diff --git a/app/Http/Controllers/MainController.php b/app/Http/Controllers/MainController.php index 0bd0dbd..cc9319f 100644 --- a/app/Http/Controllers/MainController.php +++ b/app/Http/Controllers/MainController.php @@ -601,10 +601,35 @@ class MainController extends Controller return view('house.post', compact('house', 'houses', 'count_user', 'title')); } + public function preview_PDF(House $house) { + if (!empty($house->foto_main)) { + $file_img = base64_encode(file_get_contents(public_path("storage/".$house->foto_main))); + } else { + $file_img = ""; + } + + $arr_house = ['0' => $house, 'image' => $file_img]; + view()->share('house',$arr_house); + $pdf = PDF::loadView('house.pdf', $arr_house); + return $pdf->stream(); + } + public function generate_PDF(House $house) { $arr_house = ['0' => $house]; view()->share('house',$arr_house); - $pdf = PDF::loadView('house.pdf', $arr_house); + $PDFOptions = ['enable_remote' => true, 'chroot' => public_path('storage/app/public')]; + //$PDFOptions = ['isHtml5ParserEnabled' => true, 'isRemoteEnabled' => true]; + $pdf = PDF::setOptions($PDFOptions)->loadView('house.pdf', $arr_house); + //$pdf = PDF::loadView('house.pdf', $arr_house); + /*$pdf->getDomPDF()->setHttpContext( + stream_context_create([ + 'ssl' => [ + 'allow_self_signed'=> TRUE, + 'verify_peer' => FALSE, + 'verify_peer_name' => FALSE, + ], + ]) + );*/ $id = $house->id; return $pdf->download("pdf_file_".$id.".pdf"); } diff --git a/public/storage/.gitignore b/public/storage/.gitignore new file mode 100644 index 0000000..d6b7ef3 --- /dev/null +++ b/public/storage/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/resources/views/house/pdf.blade.php b/resources/views/house/pdf.blade.php index 5327e01..0ea36ce 100644 --- a/resources/views/house/pdf.blade.php +++ b/resources/views/house/pdf.blade.php @@ -20,8 +20,17 @@ +foto_main)) {?> + + + +foto_main)) {?> + + +
- Страница помещения + {{ route('offer', ['house' => $house[0]->id]) }}

{{ $house[0]->title }} {{ $house[0]->address }}

@@ -35,7 +44,7 @@
Аренда в год за м2: {{ $house[0]->rent_in_year }} ₽
Аренда в месяц: {{ $house[0]->price }} ₽
-
Схема сделки: {{ $house[0]->scheme_deal }}
Площадь, м2: {{ $house[0]->area }}
+
Схема сделки: {{ $house[0]->scheme_deal }}
Площадь, м2: {{ $house[0]->area }}
Адрес: {{ $house[0]->address }}
Тип объекта: {{ $house[0]->typearea->name_type }}
diff --git a/resources/views/house/post.blade.php b/resources/views/house/post.blade.php index 290492d..b20a450 100644 --- a/resources/views/house/post.blade.php +++ b/resources/views/house/post.blade.php @@ -171,7 +171,7 @@
- Скачать презентацию + Скачать презентацию diff --git a/resources/views/layout/site.blade.php b/resources/views/layout/site.blade.php index 74b0be0..b4a50f6 100644 --- a/resources/views/layout/site.blade.php +++ b/resources/views/layout/site.blade.php @@ -143,7 +143,7 @@