Skip to content

Commit

Permalink
Add basic macro API
Browse files Browse the repository at this point in the history
  • Loading branch information
0x1DEA committed Sep 13, 2023
1 parent 412220d commit 333a3dd
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions routes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,23 @@

});

Route::get('/macros', function (Request $request) {
$macros = \App\Models\Game\LevelReplay::query()->whereNotNull('created_at');

if ($request->has('format') && $request->string('format')->isNotEmpty()) {
$macros->whereIn('format', explode(',', $request->string('format')));
}

return $macros->with(['files', 'author'])->paginate()->through(function (LevelReplay $replay) {
$replay->files->transform(function (Media $media) {
$hashids = new Hashids(bin2hex(Crypt::getKey()), 8);
$result = $hashids->encode([$media->id, 0]);
$media->setAttribute('url', route('download', $result));
return $media;
});
return $replay;
});
});

Route::get('/styles', function () {
$styles = \App\Models\Forge\Style::query()
Expand Down

0 comments on commit 333a3dd

Please sign in to comment.