i need to use multiple variables in my php use function. i wrote it like this.
public function show($id, $userid)
    {
        $auth = $userid;
        $user = User::findOrFail($id);
        $message = Message::where(function ($q) use ($id) {
          $q->where('from', $userid);
          $q->where('to', $id);
          $q->where('type', 0);
        })->orWhere(function ($q) use ($id){
          $q->where('from', $id);
          $q->where('to', $userid);
          $q->where('type', 1);
        })->with('user')->get();
        return response()->json([
          'message' => $message,
          'user' => $user
        ]);
    }
but it shows me a error Undefined variable: userid. how can i fix this. how can i user userid variable in use.
 
    