Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[V6] Update PHPDocs for IDE autocompletion #2437

Merged
merged 1 commit into from May 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/Models/Permission.php
Expand Up @@ -34,6 +34,11 @@ public function __construct(array $attributes = [])
$this->table = config('permission.table_names.permissions') ?: parent::getTable();
}

/**
* @return PermissionContract|Permission
*
* @throws PermissionAlreadyExists
*/
public static function create(array $attributes = [])
{
$attributes['guard_name'] = $attributes['guard_name'] ?? Guard::getDefaultName(static::class);
Expand Down Expand Up @@ -78,6 +83,7 @@ public function users(): BelongsToMany
* Find a permission by its name (and optionally guardName).
*
* @param string|null $guardName
* @return PermissionContract|Permission
*
* @throws PermissionDoesNotExist
*/
Expand All @@ -97,6 +103,7 @@ public static function findByName(string $name, $guardName = null): PermissionCo
*
* @param int|string $id
* @param string|null $guardName
* @return PermissionContract|Permission
*
* @throws PermissionDoesNotExist
*/
Expand All @@ -116,6 +123,7 @@ public static function findById($id, $guardName = null): PermissionContract
* Find or create permission by its name (and optionally guardName).
*
* @param string|null $guardName
* @return PermissionContract|Permission
*/
public static function findOrCreate(string $name, $guardName = null): PermissionContract
{
Expand All @@ -141,6 +149,8 @@ protected static function getPermissions(array $params = [], bool $onlyOne = fal

/**
* Get the current cached first permission.
*
* @return PermissionContract|Permission|null
*/
protected static function getPermission(array $params = []): ?PermissionContract
{
Expand Down
12 changes: 11 additions & 1 deletion src/Models/Role.php
Expand Up @@ -35,6 +35,11 @@ public function __construct(array $attributes = [])
$this->table = config('permission.table_names.roles') ?: parent::getTable();
}

/**
* @return RoleContract|Role
*
* @throws RoleAlreadyExists
*/
public static function create(array $attributes = [])
{
$attributes['guard_name'] = $attributes['guard_name'] ?? Guard::getDefaultName(static::class);
Expand Down Expand Up @@ -143,7 +148,12 @@ public static function findOrCreate(string $name, $guardName = null): RoleContra
return $role;
}

protected static function findByParam(array $params = [])
/**
* Finds a role based on an array of parameters.
*
* @return RoleContract|Role|null
*/
protected static function findByParam(array $params = []): ?RoleContract
{
$query = static::query();

Expand Down