diff --git a/app/Http/Controllers/ClientPortal/DownloadController.php b/app/Http/Controllers/ClientPortal/DownloadController.php index ee4f6451fa55..00682336c0c8 100644 --- a/app/Http/Controllers/ClientPortal/DownloadController.php +++ b/app/Http/Controllers/ClientPortal/DownloadController.php @@ -12,13 +12,32 @@ namespace App\Http\Controllers\ClientPortal; -use App\Models\Document; use App\Http\Controllers\Controller; +use App\Http\Requests\Document\ShowDocumentRequest; +use App\Models\Document; +use App\Utils\Traits\MakesHash; class DownloadController extends Controller { + use MakesHash; + + /** + * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View + */ public function index() { return render('downloads.index'); } + + /** + * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View + */ + public function show(ShowDocumentRequest $request, $document) + { + $document = Document::findOrFail($document); + + return render('downloads.show', [ + 'document' => $document, + ]); + } } diff --git a/app/Http/Livewire/DownloadsTable.php b/app/Http/Livewire/DownloadsTable.php index fc01938fbc6d..d8225b647990 100644 --- a/app/Http/Livewire/DownloadsTable.php +++ b/app/Http/Livewire/DownloadsTable.php @@ -15,7 +15,7 @@ class DownloadsTable extends Component public function render() { - $query = auth()->user()->client->documents() + $query = Document::query() ->orderBy($this->sort_field, $this->sort_asc ? 'asc' : 'desc') ->paginate($this->per_page); diff --git a/app/Http/Requests/Document/ShowDocumentRequest.php b/app/Http/Requests/Document/ShowDocumentRequest.php index 5be9f7b248f9..333987632439 100644 --- a/app/Http/Requests/Document/ShowDocumentRequest.php +++ b/app/Http/Requests/Document/ShowDocumentRequest.php @@ -22,7 +22,8 @@ class ShowDocumentRequest extends Request */ public function authorize() : bool { - return auth()->user()->can('view', $this->document); + return true; + // return auth()->user()->can('view', $this->document); } /** diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index 8ec1e45ffdd7..d0ef20158f8d 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -3251,4 +3251,8 @@ return [ 'width' => 'Width', 'height' => 'Height', + + 'document_details' => 'Details about the document', + + 'hash' => 'Hash', ]; diff --git a/resources/views/portal/ninja2020/components/livewire/downloads-table.blade.php b/resources/views/portal/ninja2020/components/livewire/downloads-table.blade.php index 6e15a019a5ec..0413d185eb7f 100644 --- a/resources/views/portal/ninja2020/components/livewire/downloads-table.blade.php +++ b/resources/views/portal/ninja2020/components/livewire/downloads-table.blade.php @@ -38,6 +38,7 @@ {{ ctrans('texts.download') }} + @@ -60,6 +61,11 @@ + + + {{ ctrans('texts.view') }} + + @empty diff --git a/resources/views/portal/ninja2020/downloads/show.blade.php b/resources/views/portal/ninja2020/downloads/show.blade.php new file mode 100644 index 000000000000..b7f4ae5ebc70 --- /dev/null +++ b/resources/views/portal/ninja2020/downloads/show.blade.php @@ -0,0 +1,80 @@ +@extends('portal.ninja2020.layout.app') +@section('meta_title', ctrans('texts.document')) + +@section('body') +
+
+
+
+
+

+ {{ ctrans('texts.document') }} +

+

+ {{ ctrans('texts.document_details') }} +

+
+
+
+
+
+ {{ ctrans('texts.name') }} +
+
+ {{ Illuminate\Support\Str::limit($document->name, 40) }} + + + + + + + +
+
+
+
+ {{ ctrans('texts.type') }} +
+
+ {{ App\Models\Document::$types[$document->type]['mime'] }} +
+
+
+
+ {{ ctrans('texts.hash') }} +
+
+ {{ $document->hash }} +
+
+
+
+ {{ ctrans('texts.size') }} +
+
+ {{ $document->size / 1000 }} kB +
+
+
+
+ {{ ctrans('texts.width') }} +
+
+ {{ $document->width }}px +
+
+
+
+ {{ ctrans('texts.height') }} +
+
+ {{ $document->height }}px +
+
+
+
+
+
+
+
+@endsection \ No newline at end of file diff --git a/routes/client.php b/routes/client.php index 29546eb1f976..bb8ae474afcb 100644 --- a/routes/client.php +++ b/routes/client.php @@ -60,7 +60,7 @@ Route::group(['middleware' => ['auth:contact','locale'], 'prefix' => 'client', ' Route::get('client/switch_company/{contact}', 'ClientPortal\SwitchCompanyController')->name('switch_company'); - Route::resource('downloads', 'ClientPortal\DownloadController'); + Route::resource('downloads', 'ClientPortal\DownloadController')->only(['index', 'show']); Route::get('logout', 'Auth\ContactLoginController@logout')->name('logout'); });