]> git.localhorst.tv Git - alttp.git/blob - app/Http/Controllers/AosSeedController.php
7c7e5f9fdaf04012e1f52def459b52bfabc8b88e
[alttp.git] / app / Http / Controllers / AosSeedController.php
1 <?php
2
3 namespace App\Http\Controllers;
4
5 use App\Models\AosSeed;
6 use Illuminate\Http\Request;
7 use Illuminate\Support\Facades\Artisan;
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                         Artisan::call('aos:generate '.intval($seed->id));
32                 }
33
34                 return $seed->toJson();
35         }
36
37 }