Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.2 kB
3
Indexable
Never
public function downline()
    {
        if (Auth::user()->role == 'regular') {
            $Underline = User::where('usernameSponsor', Auth::user()->usernameSponsor)->paginate(3);
            return response()->json([
                'data' => $Underline,
            ], 200);
        } elseif (Auth::user()->role == 'marshall') {
            $Underline = User::where('usernameSponsor', Auth::user()->usernameSponsor)->paginate(7);
            return response()->json([
                'data' => $Underline,
            ], 200);
        } else {
            return response()->json([
                'message' => 'Anda Tidak Memiliki Downline',
            ], 404);
        }
    }

    public function user($sponsor)
    {
        if (Auth::user()->role == 'regular') {
            $user = User::where('usernameSponsor', $sponsor)->paginate(50);
            return response()->json([
                'data' => $user,
            ], 200);
        } elseif (Auth::user()->role == 'marshall'){
            $user = User::where('usernameSponsor', $sponsor)->paginate(100);
            return response()->json([
                'data' => $user,
            ], 200);
        }
    }