April 2026 waren Wirtschaft Feedback
This commit is contained in:
parent
02f2a4c23e
commit
9ce711d6b2
167 changed files with 25278 additions and 8518 deletions
|
|
@ -2,11 +2,15 @@
|
|||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Storage;
|
||||
use Response;
|
||||
use App\Models\File;
|
||||
use App\Models\ShoppingOrder;
|
||||
use App\Models\UserCredit;
|
||||
use App\Services\Credit;
|
||||
use App\Services\Invoice;
|
||||
use App\Services\PDFMerger;
|
||||
use Auth;
|
||||
use Response;
|
||||
use Storage;
|
||||
|
||||
class FileController extends Controller
|
||||
{
|
||||
|
|
@ -15,58 +19,63 @@ class FileController extends Controller
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct() {}
|
||||
|
||||
private function isPermission($user_id)
|
||||
{
|
||||
}
|
||||
|
||||
private function isPermission($user_id){
|
||||
|
||||
if(Auth::user()->isAdmin() || $user_id == Auth::user()->id){
|
||||
if (Auth::user()->isAdmin() || $user_id == Auth::user()->id) {
|
||||
return true;
|
||||
}
|
||||
abort(404);
|
||||
abort(404);
|
||||
|
||||
}
|
||||
|
||||
public function show($id = null, $disk = null, $do='file')
|
||||
public function show($id = null, $disk = null, $do = 'file')
|
||||
{
|
||||
$path = "";
|
||||
$filename = "";
|
||||
$path = '';
|
||||
$filename = '';
|
||||
|
||||
if($disk === 'user'){
|
||||
$file = \App\Models\File::findOrFail($id);
|
||||
if ($disk === 'user') {
|
||||
$file = File::findOrFail($id);
|
||||
$this->isPermission($file->user_id);
|
||||
$path = Storage::disk($disk)->path($file->dir.$file->filename);
|
||||
if (file_exists($path)) {
|
||||
return Response::file($path);
|
||||
}
|
||||
}
|
||||
|
||||
if ($disk === 'invoice'){
|
||||
$shopping_order = \App\Models\ShoppingOrder::findOrFail($id);
|
||||
|
||||
if ($disk === 'invoice') {
|
||||
$shopping_order = ShoppingOrder::findOrFail($id);
|
||||
$this->isPermission($shopping_order->auth_user_id);
|
||||
$filename = Invoice::getFilename($shopping_order);
|
||||
$filename = Invoice::getFilename($shopping_order);
|
||||
$path = Invoice::getDownloadPath($shopping_order);
|
||||
}
|
||||
|
||||
|
||||
if ($disk === 'delivery'){
|
||||
$shopping_order = \App\Models\ShoppingOrder::findOrFail($id);
|
||||
|
||||
if ($disk === 'delivery') {
|
||||
$shopping_order = ShoppingOrder::findOrFail($id);
|
||||
$this->isPermission($shopping_order->auth_user_id);
|
||||
$filename = Invoice::getDeliveryFilename($shopping_order);
|
||||
$filename = Invoice::getDeliveryFilename($shopping_order);
|
||||
$path = Invoice::getDownloadPathDelivery($shopping_order);
|
||||
}
|
||||
|
||||
if ($disk === 'invoice_delivery'){
|
||||
$shopping_order = \App\Models\ShoppingOrder::findOrFail($id);
|
||||
if ($disk === 'cancellation') {
|
||||
$shopping_order = ShoppingOrder::findOrFail($id);
|
||||
$this->isPermission($shopping_order->auth_user_id);
|
||||
$filename = Invoice::getCancellationFilename($shopping_order);
|
||||
$path = Invoice::getCancellationDownloadPath($shopping_order);
|
||||
}
|
||||
|
||||
if ($disk === 'invoice_delivery') {
|
||||
$shopping_order = ShoppingOrder::findOrFail($id);
|
||||
$this->isPermission($shopping_order->auth_user_id);
|
||||
|
||||
$ifilename = Invoice::getFilename($shopping_order);
|
||||
$ifilename = Invoice::getFilename($shopping_order);
|
||||
$ipath = Invoice::getDownloadPath($shopping_order, true);
|
||||
$dfilename = Invoice::getDeliveryFilename($shopping_order);
|
||||
$dfilename = Invoice::getDeliveryFilename($shopping_order);
|
||||
$dpath = Invoice::getDownloadPathDelivery($shopping_order, true);
|
||||
|
||||
$oMerger = new \App\Services\PDFMerger();
|
||||
$oMerger = new PDFMerger;
|
||||
$oMerger->init();
|
||||
|
||||
$oMerger->addPDF($ipath);
|
||||
|
|
@ -75,61 +84,61 @@ class FileController extends Controller
|
|||
$oMerger->setFileName($filename);
|
||||
$oMerger->merge();
|
||||
$file = $oMerger->output();
|
||||
|
||||
return Response::make($file, 200)
|
||||
->header("Content-Type", 'application/pdf')
|
||||
->header('Content-Type', 'application/pdf')
|
||||
->header('Content-disposition', 'attachment; filename="'.$filename.'"');
|
||||
}
|
||||
|
||||
if ($disk === 'credit'){
|
||||
$UserCredit = \App\Models\UserCredit::findOrFail($id);
|
||||
|
||||
if ($disk === 'credit') {
|
||||
$UserCredit = UserCredit::findOrFail($id);
|
||||
$this->isPermission($UserCredit->auth_user_id);
|
||||
$filename = Credit::getFilename($UserCredit);
|
||||
$filename = Credit::getFilename($UserCredit);
|
||||
$path = Credit::getDownloadPath($UserCredit);
|
||||
}
|
||||
|
||||
if (!Storage::disk('public')->exists($path)) {
|
||||
if (! Storage::disk('public')->exists($path)) {
|
||||
return Response::make('File no found.', 404);
|
||||
}
|
||||
|
||||
$file = Storage::disk('public')->get($path);
|
||||
$mime = Storage::disk('public')->mimeType($path);
|
||||
|
||||
if($do === 'download'){
|
||||
if ($do === 'download') {
|
||||
return Response::make($file, 200)
|
||||
->header("Content-Type", $mime)
|
||||
->header('Content-Type', $mime)
|
||||
->header('Content-disposition', 'attachment; filename="'.$filename.'"');
|
||||
/* $full_path = Invoice::getDownloadPath($shopping_order, true);
|
||||
$he
|
||||
if (file_exists($full_path)) {
|
||||
return Response::download($full_path, $filename);
|
||||
}*/
|
||||
/* $full_path = Invoice::getDownloadPath($shopping_order, true);
|
||||
$he
|
||||
if (file_exists($full_path)) {
|
||||
return Response::download($full_path, $filename);
|
||||
}*/
|
||||
}
|
||||
if($do === 'stream'){
|
||||
if ($do === 'stream') {
|
||||
return Response::make($file, 200)
|
||||
->header("Content-Type", $mime)
|
||||
->header('Content-disposition','filename="'.$filename.'"');
|
||||
}
|
||||
|
||||
if($do === 'file'){
|
||||
return Response::make($file, 200)
|
||||
->header("Content-Type", $mime)
|
||||
->header('Content-Type', $mime)
|
||||
->header('Content-disposition', 'filename="'.$filename.'"');
|
||||
}
|
||||
if($do === 'image'){
|
||||
return Response::make($file, 200)
|
||||
->header("Content-Type", $mime);
|
||||
}
|
||||
if($do === 'pdf'){
|
||||
$path = storage_path().'/app/public/' . $path;
|
||||
$headers = array(
|
||||
'Content-Type:'. $mime,
|
||||
// 'Content-Length: ' . $file->size
|
||||
// 'Content-Disposition: ' . $stream . '; filename=' . $file->original_name
|
||||
);
|
||||
return Response::download($path, $filename, $headers);
|
||||
}
|
||||
|
||||
if ($do === 'file') {
|
||||
return Response::make($file, 200)
|
||||
->header('Content-Type', $mime)
|
||||
->header('Content-disposition', 'filename="'.$filename.'"');
|
||||
}
|
||||
if ($do === 'image') {
|
||||
return Response::make($file, 200)
|
||||
->header('Content-Type', $mime);
|
||||
}
|
||||
if ($do === 'pdf') {
|
||||
$path = storage_path().'/app/public/'.$path;
|
||||
$headers = [
|
||||
'Content-Type:'.$mime,
|
||||
// 'Content-Length: ' . $file->size
|
||||
// 'Content-Disposition: ' . $stream . '; filename=' . $file->original_name
|
||||
];
|
||||
|
||||
return Response::download($path, $filename, $headers);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue