Файловый менеджер - Редактировать - /home/clickysoft/public_html/somni.clickysoft.net/app/Http/Controllers/PdfController.php
Назад
<?php namespace App\Http\Controllers; use Illuminate\Http\Request; use App\Models\Transaction; use Illuminate\Support\Facades\Storage; use App\Helpers\Helper; class PdfController extends Controller { public function generatePDF(Request $request){ $url = env('PDF_URL','http://localhost').':3049/generate-transaction'; $montly_payment = null; $unit = null; $transactions = Transaction::with(['payee' => function($query){ $query->select('id','name'); },'transactionDetails' => function($query){ $query->select('id','payment_month','payment_year','amount','payment_type','unit_id','note','transaction_id','created_at'); },'transactionDetails.unit' => function($query){ $query->select('id','number','property_id','rent_due_date','monthly_rent'); }])->whereId($request->id)->first()->toArray(); foreach($transactions['transaction_details'] as $detail){ if($detail['payment_type'] =='monthly_rent'){ $montly_payment = $detail; $unit = $detail['unit']; } unset($detail['unit']['images']); // $detail['unit']['images'] = null; // dd($detail['unit']['images']);6t } if($montly_payment != null && $unit != null){ $transactions['period'] = Helper::calculateBillingPeriod($montly_payment['payment_month'],$montly_payment['payment_year'],$unit['rent_due_date']); } $transactions['url'] = config('app.url'); // dd($transactions); /* Init cURL resource */ $ch = curl_init($url); $data = array( 'transactions' => $transactions, // Your POST data goes here ); /* pass encoded JSON string to the POST fields */ // curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data)); /* set the content type json */ curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/x-www-form-urlencoded', 'Accept:application/json')); /* set return type json */ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); /* execute request */ $result = curl_exec($ch); /* close cURL resource */ curl_close($ch); $fileContent = base64_decode($result); $filename = 'example_file_' . uniqid() . '.pdf'; // Save the file to the storage folder Storage::put($filename, $fileContent); // If you want to save to a specific folder within the storage directory $folder = '/public/pdf_folder'; Storage::makeDirectory($folder); Storage::put("{$folder}/{$filename}", $fileContent); $fileUrl = Storage::url($filename); $accessibleLink = url($fileUrl); return response()->json([ 'url' => $accessibleLink, ]); } }
| ver. 1.4 |
Github
|
.
| PHP 8.1.29 | Генерация страницы: 0 |
proxy
|
phpinfo
|
Настройка