1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-14 15:13:29 +01:00
invoiceninja/app/Http/Controllers/Reports/ReportPreviewController.php

47 lines
1000 B
PHP
Raw Normal View History

2023-08-18 13:36:50 +02:00
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2023. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\Http\Controllers\Reports;
use App\Http\Controllers\BaseController;
use App\Http\Requests\Report\ReportPreviewRequest;
2023-10-26 04:57:44 +02:00
use App\Utils\Traits\MakesHash;
use Illuminate\Support\Facades\Cache;
2023-08-18 13:36:50 +02:00
class ReportPreviewController extends BaseController
{
use MakesHash;
public function __construct()
{
parent::__construct();
}
public function __invoke(ReportPreviewRequest $request, ?string $hash)
{
$report = Cache::get($hash);
2023-10-26 04:57:44 +02:00
if(!$report) {
2023-08-18 13:36:50 +02:00
return response()->json(['message' => 'Still working.....'], 409);
2023-10-26 04:57:44 +02:00
}
2024-01-14 05:05:00 +01:00
2023-10-26 04:57:44 +02:00
if($report) {
2024-01-14 05:05:00 +01:00
2023-08-18 13:36:50 +02:00
Cache::forget($hash);
return response()->json($report, 200);
}
}
}