File size: 1,120 Bytes
5f32fbd | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | <?php
namespace App\Http\Controllers\Common;
use App\Http\Controllers\Controller;
use Carbon\Carbon;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Artisan;
use Spatie\Health\Commands\RunHealthChecksCommand;
use Spatie\Health\ResultStores\ResultStore;
use Throwable;
class HealthController extends Controller
{
public function index()
{
$resultStore = App::make(ResultStore::class);
$checkResults = $resultStore->latestResults();
// call new status when visit the page
Artisan::call(RunHealthChecksCommand::class);
return view('panel.admin.health.index', [
'lastRanAt' => new Carbon($checkResults?->finishedAt),
'checkResults' => $checkResults,
]);
}
public function logs()
{
return view('panel.admin.health.logs');
}
public function cacheClear()
{
try {
Artisan::call('optimize:clear');
return response()->json(['success' => true]);
} catch (Throwable $th) {
return response()->json(['success' => false]);
}
}
}
|