Upload Files Booking, Mails, Attachments,
This commit is contained in:
parent
5daea268f7
commit
68b9d1ff88
92 changed files with 2837 additions and 1778 deletions
91
app/Http/Controllers/FileController.php
Executable file
91
app/Http/Controllers/FileController.php
Executable file
|
|
@ -0,0 +1,91 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
|
||||
use Response;
|
||||
use Storage;
|
||||
|
||||
class FileController extends Controller
|
||||
{
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
public function show($id = null, $disk = null, $do='file')
|
||||
{
|
||||
$path = "";
|
||||
$filename = "";
|
||||
if ($disk === 'customer'){
|
||||
$file = \App\Models\CustomerFile::findOrFail($id);
|
||||
$filename = $file->original_name;
|
||||
$path = $file->getPath();
|
||||
}
|
||||
|
||||
if ($disk === 'booking'){
|
||||
$file = \App\Models\BookingFile::findOrFail($id);
|
||||
$filename = $file->original_name;
|
||||
$path = $file->getPath();
|
||||
}
|
||||
|
||||
if ($disk === 'cms_file'){
|
||||
$file = \App\Models\CMSContent::findOrFail($id);
|
||||
$filename = $file->name;
|
||||
$path = $file->getPath();
|
||||
}
|
||||
|
||||
if (file_exists($path)) {
|
||||
if($do === "download"){
|
||||
return Response::download($path, $filename);
|
||||
}
|
||||
return Response::file($path);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function showExpert($type = null, $class = null, $year = null, $file = null, $do = null) {
|
||||
|
||||
/*if ($type == 'xls') {
|
||||
$path = storage_path("app/export/");
|
||||
$filename = $file . '.xls';
|
||||
}*/
|
||||
$path = "";
|
||||
$filename = "";
|
||||
$headers = [];
|
||||
|
||||
if ($class === 'invoices' || $class === 'infos'){
|
||||
$headers = [
|
||||
'Content-Type: application/pdf',
|
||||
'Pragma: no-cache',
|
||||
'Cache-Control: no-store,no-cache, must-revalidate, post-check=0, pre-check=0'
|
||||
];
|
||||
$dir = $year."/";
|
||||
$filename = $file;
|
||||
if ($type === 'fewo') {
|
||||
if(Storage::disk('fewo_invoices')->exists( $dir.$filename )){
|
||||
$path = Storage::disk('fewo_invoices')->path($dir.$filename);
|
||||
}
|
||||
}
|
||||
if ($type === 'fewo') {
|
||||
if(Storage::disk('fewo_infos')->exists( $dir.$filename )){
|
||||
$path = Storage::disk('fewo_infos')->path($dir.$filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (file_exists($path)) {
|
||||
if($do === "download"){
|
||||
return Response::download($path, $filename, $headers);
|
||||
}
|
||||
if($do === "file"){
|
||||
return Response::file($path, $headers);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue