mirror of
https://github.com/crater-invoice/crater.git
synced 2025-10-27 19:51:09 -04:00
v6 update
This commit is contained in:
35
app/Http/Controllers/V1/Modules/ScriptController.php
Normal file
35
app/Http/Controllers/V1/Modules/ScriptController.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace Crater\Http\Controllers\V1\Modules;
|
||||
|
||||
use Crater\Http\Controllers\Controller;
|
||||
use Crater\Services\Module\ModuleFacade;
|
||||
use DateTime;
|
||||
use Illuminate\Support\Arr;
|
||||
use Request;
|
||||
|
||||
class ScriptController extends Controller
|
||||
{
|
||||
/**
|
||||
* Serve the requested script.
|
||||
*
|
||||
* @param \Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*
|
||||
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
|
||||
*/
|
||||
public function __invoke(Request $request, string $script)
|
||||
{
|
||||
$path = Arr::get(ModuleFacade::allScripts(), $script);
|
||||
|
||||
abort_if(is_null($path), 404);
|
||||
|
||||
return response(
|
||||
file_get_contents($path),
|
||||
200,
|
||||
[
|
||||
'Content-Type' => 'application/javascript',
|
||||
]
|
||||
)->setLastModified(DateTime::createFromFormat('U', filemtime($path)));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user