i want the current user when add user in a team will save in database user id for this user not id for current user but when i use $user=User::all(); or $user=User::find($id); don't work and have error Undefined property: Illuminate\Database\Eloquent\Collection::$id and when use $user=Auth::user(); save the current user id
public function addUser($id) {
$teams =TeamWork::find($id);
$user =User::all();
$teammember = new TeamMember;
$teammember->user()->associate($user->id);
$teammember->Teamwork()->associate($teams->id);
$teammember->save();
$users = User::pluck('username');
return View('teams.adduser' , compact('users'))->with('teams', $teams);
}
Aucun commentaire:
Enregistrer un commentaire