本文整理汇总了PHP中Laravel\Spark\Spark::defaultRole方法的典型用法代码示例。如果您正苦于以下问题:PHP Spark::defaultRole方法的具体用法?PHP Spark::defaultRole怎么用?PHP Spark::defaultRole使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Laravel\Spark\Spark
的用法示例。
在下文中一共展示了Spark::defaultRole方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: attachUserToTeamByInvitation
/**
* Attach a user to a given team based on their invitation.
*
* @param string $invitationId
* @param \Illuminate\Contracts\Auth\Authenticatable $user
* @return void
*/
public function attachUserToTeamByInvitation($invitationId, $user)
{
$userModel = get_class($user);
$inviteModel = get_class((new $userModel())->invitations()->getQuery()->getModel());
$invitation = (new $inviteModel())->where('token', $invitationId)->first();
if ($invitation) {
$invitation->team->users()->attach([$user->id], ['role' => Spark::defaultRole()]);
$user->switchToTeam($invitation->team);
$invitation->delete();
}
}
示例2: customizeRoles
/**
* Customize the roles that may be assigned to team members.
*
* @return void
*/
protected function customizeRoles()
{
Spark::defaultRole('member');
Spark::roles(['admin' => 'Administrator', 'member' => 'Member']);
}
示例3: joinTeamById
/**
* Join the team with the given ID.
*
* @param int $teamId
* @return void
*/
public function joinTeamById($teamId)
{
$this->teams()->attach([$teamId], ['role' => Spark::defaultRole()]);
$this->currentTeam();
event(new JoinedTeam($this, $this->teams()->find($teamId)));
}
示例4: joinTeamById
/**
* Join the team with the given ID.
*
* @param int $teamId
* @return void
*/
public function joinTeamById($teamId)
{
$this->teams()->attach([$teamId], ['role' => Spark::defaultRole()]);
$this->currentTeam();
}
示例5: handle
/**
* {@inheritdoc}
*/
public function handle($team, $user, $role = null)
{
$team->users()->attach($user, ['role' => $role ?: Spark::defaultRole()]);
event(new TeamMemberAdded($team, $user));
}