fix: requirement of ids on request creation

IDs irrelevant to the category should not be required.
This commit is contained in:
Roardom
2023-07-10 06:42:13 +00:00
parent d95f32e6e2
commit 7f318e08d6
2 changed files with 45 additions and 19 deletions
+15 -2
View File
@@ -94,11 +94,24 @@ class RequestController extends Controller
public function create(Request $request): \Illuminate\Contracts\View\Factory|\Illuminate\View\View
{
return view('requests.create', [
'categories' => Category::orderBy('position')->get(),
'categories' => Category::orderBy('position')
->get()
->mapWithKeys(fn ($category) => [$category->id => [
'name' => $category->name,
'type' => match (1) {
$category->movie_meta => 'movie',
$category->tv_meta => 'tv',
$category->game_meta => 'game',
$category->music_meta => 'music',
$category->no_meta => 'no',
default => 'no',
},
]])
->toArray(),
'types' => Type::orderBy('position')->get(),
'resolutions' => Resolution::orderBy('position')->get(),
'user' => $request->user(),
'category_id' => $request->category_id,
'category_id' => $request->category_id ?? Category::first('id')->id,
'title' => urldecode($request->title),
'imdb' => $request->imdb,
'tmdb' => $request->tmdb,