Commit a9da0bb95e8b9da4572bb40c5a7667d084fb1f69
1 parent
995960380e
Exists in
master
Pdf-генераторы
Showing 7 changed files with 48 additions and 6 deletions Side-by-side Diff
.gitignore
app/Http/Controllers/MainController.php
... | ... | @@ -601,10 +601,35 @@ class MainController extends Controller |
601 | 601 | return view('house.post', compact('house', 'houses', 'count_user', 'title')); |
602 | 602 | } |
603 | 603 | |
604 | + public function preview_PDF(House $house) { | |
605 | + if (!empty($house->foto_main)) { | |
606 | + $file_img = base64_encode(file_get_contents(public_path("storage/".$house->foto_main))); | |
607 | + } else { | |
608 | + $file_img = ""; | |
609 | + } | |
610 | + | |
611 | + $arr_house = ['0' => $house, 'image' => $file_img]; | |
612 | + view()->share('house',$arr_house); | |
613 | + $pdf = PDF::loadView('house.pdf', $arr_house); | |
614 | + return $pdf->stream(); | |
615 | + } | |
616 | + | |
604 | 617 | public function generate_PDF(House $house) { |
605 | 618 | $arr_house = ['0' => $house]; |
606 | 619 | view()->share('house',$arr_house); |
607 | - $pdf = PDF::loadView('house.pdf', $arr_house); | |
620 | + $PDFOptions = ['enable_remote' => true, 'chroot' => public_path('storage/app/public')]; | |
621 | + //$PDFOptions = ['isHtml5ParserEnabled' => true, 'isRemoteEnabled' => true]; | |
622 | + $pdf = PDF::setOptions($PDFOptions)->loadView('house.pdf', $arr_house); | |
623 | + //$pdf = PDF::loadView('house.pdf', $arr_house); | |
624 | + /*$pdf->getDomPDF()->setHttpContext( | |
625 | + stream_context_create([ | |
626 | + 'ssl' => [ | |
627 | + 'allow_self_signed'=> TRUE, | |
628 | + 'verify_peer' => FALSE, | |
629 | + 'verify_peer_name' => FALSE, | |
630 | + ], | |
631 | + ]) | |
632 | + );*/ | |
608 | 633 | $id = $house->id; |
609 | 634 | return $pdf->download("pdf_file_".$id.".pdf"); |
610 | 635 | } |
public/storage/.gitignore
resources/views/house/pdf.blade.php
... | ... | @@ -20,8 +20,17 @@ |
20 | 20 | <link rel="stylesheet" href="{{ asset('css/style_main.css') }}"> |
21 | 21 | </head> |
22 | 22 | <body> |
23 | +<? //if (!empty($house[0]->foto_main)) {?> | |
24 | +<!--<img src="<?//=public_path().'/storage/app/public/'.$house[0]->foto_main;?>" width="450px"/> | |
25 | +<!--<img src="<?//=public_path().'/images/footer-bg.jpg';?>" />--> | |
26 | +<?//} ?> | |
27 | + | |
28 | +<? if (!empty($house[0]->foto_main)) {?> | |
29 | +<img src='data:image/png;base64,{{ $house['image'] }}' width="450px"> | |
30 | +<? } ?> | |
31 | + | |
23 | 32 | <div class="wrapper_"> |
24 | - <a href="{{ route('offer', ['house' => $house[0]->id]) }}">Страница помещения</a> | |
33 | + <a href="{{ route('offer', ['house' => $house[0]->id]) }}">{{ route('offer', ['house' => $house[0]->id]) }}</a> | |
25 | 34 | <main> |
26 | 35 | <!-- Основной контент --> |
27 | 36 | <h2>{{ $house[0]->title }} {{ $house[0]->address }}</h2> |
... | ... | @@ -35,7 +44,7 @@ |
35 | 44 | <div class="offer__line"><span><b>Аренда в год за м2:</b> {{ $house[0]->rent_in_year }} ₽</span></div> |
36 | 45 | <div class="offer__line"><span><b>Аренда в месяц:</b> {{ $house[0]->price }} ₽</span></div> |
37 | 46 | <? } ?> |
38 | - <div class="offer__line"><span><b>Схема сделки:</b> {{ $house[0]->scheme_deal }}</span></div><div class="offer__line"><span><b>Площадь, м2:</b> {{ $house[0]->area }}</span></div> | |
47 | + <div class="offer__line"><span><b>Схема сделки:</b> {{ $house[0]->scheme_deal }}</span></div> | |
39 | 48 | <div class="offer__line"><span><b>Площадь, м2:</b> {{ $house[0]->area }}</span></div> |
40 | 49 | <div class="offer__line"><span><b>Адрес: </b>{{ $house[0]->address }}</span></div> |
41 | 50 | <div class="offer__line"><span><b>Тип объекта: </b> {{ $house[0]->typearea->name_type }}</span></div> |
resources/views/house/post.blade.php
... | ... | @@ -171,7 +171,7 @@ |
171 | 171 | <svg width="22" height="22"> |
172 | 172 | <use xlink:href="{{ asset('images/sprite.svg#intro-link-phone') }}"></use> |
173 | 173 | </svg></span></a></div> |
174 | - <a class="offer-side__download" href="{{ route('pdf', ['house' => $house->id]) }}" download><span>Скачать презентацию | |
174 | + <a class="offer-side__download" target="_blank" href="{{ route('pdf.preview', ['house' => $house->id]) }}" download_><span>Скачать презентацию | |
175 | 175 | <svg width="60" height="60"> |
176 | 176 | <use xlink:href="{{ asset('images/sprite.svg#offer-side-download') }}"></use> |
177 | 177 | </svg></span></a> |
resources/views/layout/site.blade.php
... | ... | @@ -143,7 +143,7 @@ |
143 | 143 | </div> |
144 | 144 | </div> |
145 | 145 | <div class="footer__col footer__col-menu js_footer_col"> |
146 | - <h3 class="footer__caption js_footer_caption">Меню123</h3> | |
146 | + <h3 class="footer__caption js_footer_caption">Меню</h3> | |
147 | 147 | <div class="footer__block js_footer_block"> |
148 | 148 | <ul class="footer__list"> |
149 | 149 | <li class="footer__item"><a class="footer__link" href="{{ route('catalog') }}">Каталог</a></li> |
routes/web.php
1 | 1 | <?php |
2 | 2 | |
3 | +use Illuminate\Support\Facades\Artisan; | |
3 | 4 | use Illuminate\Support\Facades\Auth; |
4 | 5 | use Illuminate\Support\Facades\Route; |
5 | 6 | use App\Http\Controllers\MainController; |
... | ... | @@ -62,6 +63,8 @@ Route::get('offer/{house:id}', [MainController::class, 'offer'])->name('offer'); |
62 | 63 | //pdf-страница недвижимости |
63 | 64 | Route::get('pdf/{house:id}', [MainController::class, 'generate_PDF'])->name('pdf'); |
64 | 65 | |
66 | +Route::get('pdf/preview/{house:id}', [MainController::class, 'preview_PDF'])->name('pdf.preview'); | |
67 | + | |
65 | 68 | //Детальная страница новостей |
66 | 69 | Route::get('detail-new/{news:id}', [MainController::class, 'DetailNew'])->name('new'); |
67 | 70 | |
... | ... | @@ -77,6 +80,10 @@ Route::get('category/{cat}', [MainController::class, 'Category'])->name('categor |
77 | 80 | //Категория ajax |
78 | 81 | Route::get('category_ajax/{cat}', [MainController::class, 'category_ajax'])->name('category_ajax'); |
79 | 82 | |
83 | +Route::get('/link/', function() { | |
84 | + Artisan::call('storage:link'); | |
85 | +}); | |
86 | + | |
80 | 87 | //Страница куков |
81 | 88 | Route::get('cookies', function () { |
82 | 89 | return view('cookies'); |