本文整理匯總了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));
}