firstOrFail(); $this->authorize('view', $guild); $validatedData = $request->validate([ 'parents' => 'array|nullable', 'parents.*' => 'string', 'phrase' => 'string|nullable', 'types' => 'array|nullable', 'types.*' => 'integer', ]); $channels = $guild->channels(); if (!empty($validatedData['parents'])) { $channels = $channels->whereIn('parent', $validatedData['parents']); } if (!empty($validatedData['phrase'])) { $channels = $channels->where('name', 'LIKE', '%'.$validatedData['phrase'].'%'); } if (!empty($validatedData['types'])) { $channels = $channels->whereIn('type', $validatedData['types']); } return $channels->get()->toJson(); } public function single(Request $request, $channel_id) { $channel = DiscordChannel::where('channel_id', '=', $channel_id)->firstOrFail(); $this->authorize('view', $channel); return $channel->toJson(); } }