<?php

namespace App\Api\Http\Controllers\Api\V1\UserCategory;

use App\Api\Http\Resources\User\UserResource;
use App\Http\Controllers\Controller;
use App\User;
use Illuminate\Http\Request;

class UserCategoryController extends Controller
{
    public function getTeamLeaderByUser(Request $request)
    {
        $user = $request->id;
        $user = User::where('reporting_to', $user)
            ->where('status', 1)
            ->get();

        if ($user->isEmpty()) {
            return response()->json('No user found!');
        }

        return $this->success('Profile fetched!', UserResource::collection($user));
    }
}
