'Domain is required.', 'status' => false, ]; } // Check if domain format is valid (e.g., example.com) if (! filter_var($domain, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME)) { return [ 'error' => 'Invalid domain format.', 'status' => false, ]; } // Fetch the restaurant based on the domain $restaurant = DB::table('restaurants') ->where('domain', $domain) ->select('id') ->first(); // If no matching restaurant is found if (! $restaurant) { return [ 'error' => 'Restaurant not found for the provided domain.', 'status' => false, ]; } // Return the restaurant ID return [ 'restaurant_id' => $restaurant->id, 'status' => true, ]; } }