fix: 🐛 update document accessibility
This commit is contained in:
parent
b999d29bb1
commit
5bba7b87f4
3 changed files with 10 additions and 8 deletions
|
|
@ -209,14 +209,15 @@ class DocumentController extends Controller
|
|||
/**
|
||||
* Download the document
|
||||
*
|
||||
* @param string $tenant
|
||||
* @param string $uuid
|
||||
* @return \Symfony\Component\HttpFoundation\BinaryFileResponse
|
||||
*/
|
||||
public function download(string $uuid): \Symfony\Component\HttpFoundation\BinaryFileResponse
|
||||
public function download(string $tenant, string $uuid): \Symfony\Component\HttpFoundation\BinaryFileResponse
|
||||
{
|
||||
$doc = Document::where('uuid', $uuid)->firstOrFail();
|
||||
$pathToFile = public_path() . Storage::url(
|
||||
sprintf('docs/%s/%s.%s', \tenant()->getKey(), $doc->uuid, $doc->type)
|
||||
sprintf('docs/%s/%s.%s', $tenant, $doc->uuid, $doc->type)
|
||||
);
|
||||
return response()->download($pathToFile, $doc->path);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ use App\Traits\Models\IsRelatedToTenant;
|
|||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Str;
|
||||
use Stancl\Tenancy\Contracts\Tenant as BaseTenant;
|
||||
use Stancl\Tenancy\Database\Concerns\BelongsToTenant;
|
||||
use Uwil\LaravelCommon\Helpers\ToolboxHelper;
|
||||
|
||||
|
|
@ -104,7 +105,7 @@ class Formulary extends Model
|
|||
private static function assertNameIsUnique(
|
||||
string|null $name,
|
||||
?int $id = null,
|
||||
\App\Models\Tenant|\Stancl\Tenancy\Contracts\Tenant $tenant = null
|
||||
Tenant|BaseTenant|null $tenant = null
|
||||
) {
|
||||
$table = (new self())->getTable();
|
||||
ToolboxHelper::assertFieldIsUnique($table, 'name', $name, $id, self::whereTenantQuery($tenant));
|
||||
|
|
|
|||
|
|
@ -104,10 +104,10 @@ Route::middleware(['web', 'admin-secure'])->name('bo.')->group(function () {
|
|||
])->where('direction', 'up|down')
|
||||
->name('formularies.change-order');
|
||||
});
|
||||
|
||||
// * Public files download
|
||||
Route::get('/docs/{uuid}/download', [DocumentController::class, 'download'])
|
||||
->name('docs.download')
|
||||
->middleware('signed');
|
||||
});
|
||||
});
|
||||
|
||||
// Public files download.
|
||||
Route::get('/{tenant}/docs/{uuid}/download', [DocumentController::class, 'download'])
|
||||
->name('docs.download')
|
||||
->middleware('signed');
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue