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

Commit 497360d

Browse files
committed
fix: return type for get asset files action
1 parent 0a8496e commit 497360d

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

common/helpers.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ function lara_gen_adv_asset(string $asset): string
4646

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

49-
return route('lara_gen_adv.asset', ['asset' => $asset], $useAbsolutePath);
49+
return route('lara_gen_adv.asset', ['asset' => $asset], $useAbsolutePath).'?v='.filemtime($file);
5050
}
5151
}
5252

src/Http/Controllers/Asset/AssetController.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ class AssetController extends BaseController
1313
{
1414
/**
1515
* @param Request $request
16-
* @return string
16+
*
17+
* @return Response
1718
*/
18-
public function index(Request $request): string
19+
public function index(Request $request): Response
1920
{
2021
$fileSystem = new Filesystem();
2122
$asset = $request->offsetGet('asset');
@@ -27,16 +28,15 @@ public function index(Request $request): string
2728
$fileSystem->get($path),
2829
200,
2930
[
30-
'Content-Type' => pathinfo($asset)['extension'] == 'css'
31+
'Content-Type' => pathinfo($asset, PATHINFO_EXTENSION) == 'css'
3132
? 'text/css'
3233
: 'application/javascript',
3334
]
3435
))->setSharedMaxAge(31536000)
3536
->setMaxAge(31536000)
36-
->setExpires(new DateTime('+1 year'))
37-
->getContent();
37+
->setExpires(new DateTime('+1 year'));
3838
} catch (FileNotFoundException $e) {
39-
return $e->getMessage();
39+
return new Response($e->getMessage(), 404);
4040
}
4141
}
4242
}

0 commit comments

Comments
 (0)