mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-13 06:14:04 +00:00
Fix tenant asset controller middleware() logic
This commit is contained in:
parent
d243309bcf
commit
fdd401fc8f
2 changed files with 13 additions and 9 deletions
|
|
@ -12,14 +12,14 @@ use Illuminate\Routing\Controllers\Middleware;
|
|||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||
use Throwable;
|
||||
|
||||
class TenantAssetController implements HasMiddleware // todo@docs this was renamed from TenantAssetsController
|
||||
class TenantAssetController implements HasMiddleware
|
||||
{
|
||||
/**
|
||||
* Used for adding custom headers to the response.
|
||||
*
|
||||
* @var (Closure(Request): array)|null
|
||||
* @var (Closure(Request): array)|array
|
||||
*/
|
||||
public static Closure|null $headers;
|
||||
public static Closure|array $headers = [];
|
||||
|
||||
/**
|
||||
* Additional middleware to be used on the route to this controller.
|
||||
|
|
@ -30,12 +30,13 @@ class TenantAssetController implements HasMiddleware // todo@docs this was renam
|
|||
|
||||
public static function middleware()
|
||||
{
|
||||
return [
|
||||
new Middleware(array_merge(
|
||||
return array_map(
|
||||
fn ($middleware) => new Middleware($middleware),
|
||||
array_merge(
|
||||
[tenancy()->defaultMiddleware()],
|
||||
static::$middleware,
|
||||
)),
|
||||
];
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -46,7 +47,9 @@ class TenantAssetController implements HasMiddleware // todo@docs this was renam
|
|||
$this->validatePath($path);
|
||||
|
||||
try {
|
||||
$headers = isset(static::$headers) ? (static::$headers)($request) : [];
|
||||
$headers = static::$headers instanceof Closure
|
||||
? (static::$headers)($request)
|
||||
: static::$headers;
|
||||
|
||||
return response()->file(storage_path("app/public/$path"), $headers);
|
||||
} catch (Throwable) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue