File tree 3 files changed +30
-9
lines changed
3 files changed +30
-9
lines changed Original file line number Diff line number Diff line change @@ -174,7 +174,22 @@ public function store(StoreTorrentRequestRequest $request): \Illuminate\Http\Red
174
174
public function edit (Request $ request , TorrentRequest $ torrentRequest ): \Illuminate \Contracts \View \Factory |\Illuminate \View \View
175
175
{
176
176
return view ('requests.edit ' , [
177
- 'categories ' => Category::orderBy ('position ' )->get (),
177
+ 'categories ' => Category::query ()
178
+ ->orderBy ('position ' )
179
+ ->get ()
180
+ ->mapWithKeys (fn ($ cat ) => [
181
+ $ cat ['id ' ] => [
182
+ 'name ' => $ cat ['name ' ],
183
+ 'type ' => match (true ) {
184
+ $ cat ->movie_meta => 'movie ' ,
185
+ $ cat ->tv_meta => 'tv ' ,
186
+ $ cat ->game_meta => 'game ' ,
187
+ $ cat ->music_meta => 'music ' ,
188
+ $ cat ->no_meta => 'no ' ,
189
+ default => 'no ' ,
190
+ },
191
+ ]
192
+ ]),
178
193
'types ' => Type::orderBy ('position ' )->get (),
179
194
'resolutions ' => Resolution::orderBy ('position ' )->get (),
180
195
'user ' => $ request ->user (),
Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ class="breadcrumb__link"
30
30
<section
31
31
class =" panelV2"
32
32
x-data =" {
33
- cat: {{ (int ) $category_id } } ,
33
+ cat: {{ (int ) $torrentRequest -> category_id } } ,
34
34
cats: JSON.parse(atob('{{ base64_encode (json_encode ($categories )) } } ')),
35
35
}"
36
36
>
@@ -57,15 +57,21 @@ class="form__text"
57
57
</label >
58
58
</p >
59
59
<p class =" form__group" >
60
- <select id =" category_id" class =" form__select" name =" category_id" required >
61
- <option hidden selected disabled value =" " ></option >
62
- @foreach ($categories as $category )
60
+ <select
61
+ id =" category_id"
62
+ class =" form__select"
63
+ name =" category_id"
64
+ x-model =" cat"
65
+ required
66
+ >
67
+ <option hidden disabled selected value =" " ></option >
68
+ @foreach ($categories as $id => $category )
63
69
<option
64
70
class =" form__option"
65
- value =" {{ $category -> id } }"
66
- @selected ($torrentRequest -> category_id == $category -> id )
71
+ value =" {{ $id } }"
72
+ @selected ($id === old ( ' category_id ' , $torrentRequest -> category_id ) )
67
73
>
68
- {{ $category -> name } }
74
+ {{ $category [ ' name' ] } }
69
75
</option >
70
76
@endforeach
71
77
</select >
Original file line number Diff line number Diff line change @@ -86,7 +86,7 @@ class="form__select"
86
86
{{ $torrent -> category -> name } } ({{ __ (' torrent.current' ) } } )
87
87
</option >
88
88
@foreach ($categories as $id => $category )
89
- <option value =" {{ $id } }" @selected (' category_id' === $id )>
89
+ <option value =" {{ $id } }" @selected (old ( ' category_id' ) === $id )>
90
90
{{ $category [' name' ] } }
91
91
</option >
92
92
@endforeach
You can’t perform that action at this time.
0 commit comments