08 2024
This commit is contained in:
parent
04d677d37a
commit
bfa3bb1df4
1191 changed files with 637397 additions and 10619 deletions
|
|
@ -2,9 +2,11 @@
|
|||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Auth;
|
||||
use Storage;
|
||||
use Response;
|
||||
use Auth;
|
||||
use App\Models\UserCredit;
|
||||
use App\Repositories\CreditRepository;
|
||||
|
||||
class FileController extends Controller
|
||||
{
|
||||
|
|
@ -32,10 +34,19 @@ class FileController extends Controller
|
|||
abort(404);
|
||||
}
|
||||
|
||||
public function show($id = null, $disk = null, $do='file')
|
||||
private function isPermissionAuth(){
|
||||
if(Auth::check()){
|
||||
return true;
|
||||
}
|
||||
abort(404);
|
||||
}
|
||||
|
||||
public function show($id = null, $from = null, $do='file')
|
||||
{
|
||||
|
||||
$path = "";
|
||||
$filename = "";
|
||||
$disk = "public";
|
||||
|
||||
/*if($disk === 'user'){
|
||||
$file = \App\Models\File::findOrFail($id);
|
||||
|
|
@ -45,25 +56,19 @@ class FileController extends Controller
|
|||
return Response::file($path);
|
||||
}
|
||||
}*/
|
||||
|
||||
if ($disk === 'invoice'){
|
||||
if ($from === 'invoice'){
|
||||
$shopping_order = \App\Models\ShoppingOrder::findOrFail($id);
|
||||
if($shopping_order->user_invoice){
|
||||
$this->isPermissionShoppingOrder($shopping_order);
|
||||
$user_invoice = $shopping_order->user_invoice;
|
||||
$filename = $user_invoice->filename;
|
||||
$disk = $user_invoice->disk;
|
||||
$path = $user_invoice->getDownloadPath();
|
||||
if (!Storage::disk($disk)->exists($path)) {
|
||||
return Response::make('File no found.', 404);;
|
||||
}
|
||||
$file = Storage::disk($disk)->get($path);
|
||||
$mime = Storage::disk($disk)->mimeType($path);
|
||||
$path = $user_invoice->getDownloadPath();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if ($disk === 'delivery'){
|
||||
if ($from === 'delivery'){
|
||||
$shopping_order = \App\Models\ShoppingOrder::findOrFail($id);
|
||||
if($shopping_order->user_invoice){
|
||||
$this->isPermissionShoppingOrder($shopping_order);
|
||||
|
|
@ -71,28 +76,63 @@ class FileController extends Controller
|
|||
$filename = $user_invoice->delivery_filename;
|
||||
$disk = $user_invoice->disk;
|
||||
$path = $user_invoice->getDownloadPathDelivery();
|
||||
if (!Storage::disk($disk)->exists($path)) {
|
||||
return Response::make('File no found.', 404);;
|
||||
}
|
||||
$file = Storage::disk($disk)->get($path);
|
||||
$mime = Storage::disk($disk)->mimeType($path);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ($disk === 'credit'){
|
||||
if ($from === 'credit'){
|
||||
$user_credit = \App\Models\UserCredit::findOrFail($id);
|
||||
$this->isPermissionUserCredit($user_credit);
|
||||
$filename = $user_credit->filename;
|
||||
$disk = $user_credit->disk;
|
||||
$path = $user_credit->getDownloadPath();
|
||||
if (!Storage::disk($disk)->exists($path)) {
|
||||
return Response::make('File no found.', 404);;
|
||||
}
|
||||
$file = Storage::disk($disk)->get($path);
|
||||
$mime = Storage::disk($disk)->mimeType($path);
|
||||
}
|
||||
|
||||
if ($from === 'credit_detail'){
|
||||
$user_credit = \App\Models\UserCredit::findOrFail($id);
|
||||
$this->isPermissionUserCredit($user_credit);
|
||||
|
||||
return $this->create_credit_detail($user_credit, $do);
|
||||
|
||||
|
||||
/*
|
||||
$filename = $user_credit->filename;
|
||||
$disk = $user_credit->disk;
|
||||
$path = $user_credit->getDownloadPath();
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
if ($from === 'dc_file'){
|
||||
$this->isPermissionAuth();
|
||||
$dc_file = \App\Models\DcFile::findOrFail($id);
|
||||
$filename = $dc_file->filename;
|
||||
$disk = 'public';
|
||||
$path = $dc_file->getFile();
|
||||
}
|
||||
if ($from === 'dc_thumb'){
|
||||
$this->isPermissionAuth();
|
||||
$dc_file = \App\Models\DcFile::findOrFail($id);
|
||||
$filename = $dc_file->filename;
|
||||
$disk = 'public';
|
||||
$path = $dc_file->getThumb();
|
||||
}
|
||||
|
||||
if ($from === 'dc_big'){
|
||||
$this->isPermissionAuth();
|
||||
$dc_file = \App\Models\DcFile::findOrFail($id);
|
||||
$filename = $dc_file->filename;
|
||||
$disk = 'public';
|
||||
$path = $dc_file->getBig();
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(!Storage::disk($disk)->exists($path)){
|
||||
// return Response::make('File no found.', 404);
|
||||
}
|
||||
$file = Storage::disk($disk)->get($path);
|
||||
$mime = Storage::disk($disk)->mimeType($path);
|
||||
|
||||
if(isset($file)){
|
||||
if($do === 'download'){
|
||||
return Response::make($file, 200)
|
||||
|
|
@ -104,34 +144,35 @@ class FileController extends Controller
|
|||
->header("Content-Type", $mime)
|
||||
->header('Content-disposition','inline; filename="'.$filename.'"');
|
||||
}
|
||||
|
||||
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 = array(
|
||||
'Content-Type:'. $mime,
|
||||
// 'Content-Length: ' . $file->size
|
||||
// 'Content-Disposition: ' . $stream . '; filename=' . $file->original_name
|
||||
);
|
||||
|
||||
return Response::download($path, $filename, $headers);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*if ($disk === 'credit'){
|
||||
$this->isPermission($UserCredit->auth_user_id);
|
||||
|
||||
$filename = Credit::getFilename($UserCredit);
|
||||
$path = Credit::getDownloadPath($UserCredit);
|
||||
|
||||
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'){
|
||||
return Response::make($file, 200)
|
||||
->header("Content-Type", $mime)
|
||||
->header('Content-disposition', 'attachment; filename="'.$filename.'"');
|
||||
}
|
||||
if($do === 'stream'){
|
||||
return Response::make($file, 200)
|
||||
->header("Content-Type", $mime)
|
||||
->header('Content-disposition','filename="'.$filename.'"');
|
||||
}
|
||||
|
||||
}*/
|
||||
|
||||
}
|
||||
|
||||
private function create_credit_detail(UserCredit $user_credit, $do){
|
||||
|
||||
$credit_repo = new CreditRepository($user_credit->user);
|
||||
return $credit_repo->create_report($user_credit, $do);
|
||||
//\Session()->flash('alert-success', "Gutschrift erstellt");
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue