]> git.localhorst.tv Git - alttp.git/blob - app/Http/Controllers/AosSeedController.php
9d35bc09fd0fcc44324a94178665f0158c974a9f
[alttp.git] / app / Http / Controllers / AosSeedController.php
1 <?php
2
3 namespace App\Http\Controllers;
4
5 use App\Jobs\GenerateAosSeed;
6 use App\Models\AosSeed;
7 use Illuminate\Http\Request;
8
9 class AosSeedController extends Controller
10 {
11
12         public function byHash($hash) {
13                 $seed = AosSeed::where('hash', '=', $hash)->firstOrFail();
14
15                 if ($seed->race) {
16                         $seed->makeHidden('seed');
17                 }
18                 if ($seed->mystery) {
19                         $seed->makeHidden('settings');
20                 }
21
22                 return $seed->toJson();
23         }
24
25         public function retry($hash) {
26                 $seed = AosSeed::where('hash', '=', $hash)->firstOrFail();
27
28                 if ($seed->status == 'error') {
29                         $seed->status = 'pending';
30                         $seed->save();
31                         GenerateAosSeed::dispatch($seed)->onConnection('database');
32                 }
33
34                 return $seed->toJson();
35         }
36
37 }