]> git.localhorst.tv Git - alttp.git/blob - app/Http/Controllers/AlttpSeedController.php
basic content editing
[alttp.git] / app / Http / Controllers / AlttpSeedController.php
1 <?php
2
3 namespace App\Http\Controllers;
4
5 use App\Models\AlttpSeed;
6 use Illuminate\Http\Request;
7 use Illuminate\Support\Facades\Artisan;
8
9 class AlttpSeedController extends Controller
10 {
11
12         public function byHash($hash) {
13                 $seed = AlttpSeed::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 = AlttpSeed::where('hash', '=', $hash)->firstOrFail();
27
28                 if ($seed->status == 'error') {
29                         $seed->status = 'pending';
30                         $seed->save();
31                         Artisan::call('alttp:generate '.intval($seed->id));
32                 }
33
34                 return $seed->toJson();
35         }
36
37 }