listing files in backend
This commit is contained in:
parent
4ac1c34b6a
commit
ccff83fa66
9 changed files with 153 additions and 93 deletions
|
@ -11,6 +11,7 @@ use Illuminate\View\View;
|
|||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\File;
|
||||
|
||||
class DatasetController extends Controller
|
||||
{
|
||||
|
@ -109,7 +110,7 @@ class DatasetController extends Controller
|
|||
public function edit($id) : View
|
||||
{
|
||||
$document = Dataset::findOrFail($id);
|
||||
$document->load('licenses', 'titles', 'abstracts');
|
||||
$document->load('licenses', 'titles', 'abstracts', 'files');
|
||||
|
||||
$projects = Project::pluck('label', 'id');
|
||||
|
||||
|
@ -191,6 +192,7 @@ class DatasetController extends Controller
|
|||
return redirect()->route('settings.document');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
|
|
18
app/Http/Controllers/Settings/FileController.php
Normal file
18
app/Http/Controllers/Settings/FileController.php
Normal file
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
namespace App\Http\Controllers\Settings;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\View\View;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\File;
|
||||
|
||||
class FileController extends Controller
|
||||
{
|
||||
public function download($id)
|
||||
{
|
||||
//$report = $this->report->find($id);
|
||||
$file = File::findOrFail($id);
|
||||
$file_path = public_path('storage/' . $file->path_name);
|
||||
return response()->download($file_path, $file->label, ['Content-Type:' . $file->mime_type]);
|
||||
}
|
||||
}
|
|
@ -66,4 +66,9 @@ class File extends Model
|
|||
{
|
||||
return storage_path('app/public/' . $this->path_name);
|
||||
}
|
||||
|
||||
public function exists()
|
||||
{
|
||||
return \Illuminate\Support\Facades\File::exists(public_path('storage/' . $this->path_name));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
editor.link_modal.header
Reference in a new issue