Skip to content
This repository has been archived by the owner on Jan 15, 2024. It is now read-only.

Commit

Permalink
fix: return type for get asset files action
Browse files Browse the repository at this point in the history
  • Loading branch information
tanhongit committed Jan 10, 2024
1 parent 0a8496e commit 497360d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion common/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function lara_gen_adv_asset(string $asset): string

$useAbsolutePath = config('lara-gen-adv.defaults.paths.use_absolute_path');

return route('lara_gen_adv.asset', ['asset' => $asset], $useAbsolutePath);
return route('lara_gen_adv.asset', ['asset' => $asset], $useAbsolutePath).'?v='.filemtime($file);
}
}

Expand Down
12 changes: 6 additions & 6 deletions src/Http/Controllers/Asset/AssetController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ class AssetController extends BaseController
{
/**
* @param Request $request
* @return string
*
* @return Response
*/
public function index(Request $request): string
public function index(Request $request): Response
{
$fileSystem = new Filesystem();
$asset = $request->offsetGet('asset');
Expand All @@ -27,16 +28,15 @@ public function index(Request $request): string
$fileSystem->get($path),
200,
[
'Content-Type' => pathinfo($asset)['extension'] == 'css'
'Content-Type' => pathinfo($asset, PATHINFO_EXTENSION) == 'css'

Check failure on line 31 in src/Http/Controllers/Asset/AssetController.php

View workflow job for this annotation

GitHub Actions / PHPStan - P8.1

Parameter #1 $path of function pathinfo expects string, mixed given.

Check failure on line 31 in src/Http/Controllers/Asset/AssetController.php

View workflow job for this annotation

GitHub Actions / PHPStan - P8.2

Parameter #1 $path of function pathinfo expects string, mixed given.
? 'text/css'
: 'application/javascript',
]
))->setSharedMaxAge(31536000)
->setMaxAge(31536000)
->setExpires(new DateTime('+1 year'))
->getContent();
->setExpires(new DateTime('+1 year'));
} catch (FileNotFoundException $e) {
return $e->getMessage();
return new Response($e->getMessage(), 404);
}
}
}

0 comments on commit 497360d

Please sign in to comment.