/** * Give a user a Role * * @param $user_id * @param $role_id */ public function giveUserRole($user_id, $role_id) { $user = UserModel::find($user_id); $role = RoleModel::firstOrNew(['id' => $role_id]); // If the role does not already have the user // add it. if (!$role->users->contains($user->id)) { $role->users()->save($user); } return; }
public function testUser() { $slack = SlackUser::where('user_id', '=', 3)->first(); $artifact = User::find(3); $this->assertEquals($artifact, $slack->user); }
public function testUser() { $permission = SlackChannelUser::where('user_id', '=', 1)->first(); $artifact = User::find(1); $this->assertEquals($artifact, $permission->user); }