This image for my pivot table:
and the code below has for relationship
return $this->belongsToMany(User::class, 'user_team', 'team_id', 'user_id')->withPivot('post');
and in controller im use this code:
$usersTeam = Team::find($id)->users()->get();
return json_encode($usersTeam);
and pic below is response:
Now, im want if post is 0 return in json: "post": "leader" and if 1 return "post": "member"
How should I do this?
Thanks a lot

