query('source_code', '')); if (! preg_match('/^[A-Za-z0-9_-]{2,64}$/', $sourceCode)) { return response()->json(['valid' => false]); } $channel = PublicSourceChannel::query() ->where('source_code', $sourceCode) ->where('status', PublicSourceChannel::STATUS_ENABLED) ->first(); if ($channel === null) { return response()->json(['valid' => false]); } return response()->json([ 'valid' => true, 'source_code' => $channel->source_code, 'source_name' => $channel->source_name, ]); } }