Exemple #1
0
    $start2 = json_decode($inputs['data'], true);
    if (Util::exists('api_start2.json')) {
        $data = Util::load('api_start2.json');
        if (Util::compareJson($data, $start2)) {
            return Util::errorResponse('duplicate start2 data');
        }
    }
    Util::dump('api_start2.json', $start2);
    $datetime = new DateTime();
    $today = $datetime->format('YmdH');
    Util::dump("start2/{$today}.json", $start2);
    Queue::push(function ($job) {
        Artisan::call('parse:start2');
        $job->delete();
    });
    return Util::successResponse();
});
$app->get('/start2', function () {
    try {
        $data = Util::read('api_start2.json');
        return response($data)->header('Content-Type', 'application/json');
    } catch (FileNotFoundException $e) {
        return Util::errorResponse('api_start2.json not found in server');
    }
});
$app->get('/start2/archives', function () {
    $files = Storage::disk('local')->files('start2');
    $list = [];
    $matches = [];
    foreach ($files as $file) {
        preg_match('/\\d{8,12}/', $file, $matches);