<commit_before>---
sidebarDepth: 2
---

# API

## User
* ### `public cachedRoles`
  - **Returns:** `Illuminate\Database\Eloquent\Collection|array`
  - **Usage:**

    Get the user cached roles. If the `laratrust.use_cache` is set to `true` it will return an array and if it set to `false` it will return a collection.

- ### `public cachedPermissions`
  - **Returns:** `Illuminate\Database\Eloquent\Collection|array`
  - **Usage:**

    Get the user cached permissions. If `laratrust.use_cache` is set to `true` it will return an array and if it set to `false` it will return a collection.

- ### `public roles`
  - **Returns:** `Illuminate\Database\Eloquent\Relations\MorphToMany`
  - **Usage:**

    Get the morph to many user relationship with the roles.

- ### `public rolesTeams`
  - **Returns:** `Illuminate\Database\Eloquent\Relations\MorphToMany|null`
  - **Usage:**

    Get the morph to many user relationship with the teams through the roles. If `laratrust.use_teams` is set to `false` it will return null.

- ### `public permissions`
  - **Returns:** `Illuminate\Database\Eloquent\Relations\MorphToMany`
  - **Usage:**

    Get the morph to many user relationship with the permissions.

- ### `public hasRole`
  - **Arguments:**
    - `$role (string, int, Illuminate\Database\Eloquent\Model)`
    - `$team = null`
    - `$requireAll = false`
  - **Returns:** `bool`
  - **Usage:**

    Check if an user has some role(s).
    ```php
    $user->hasRole('admin');
    $user->hasRole(['admin', 'regular']);
    $user->hasRole(['admin', 'regular'], true); // Will require all
    ```

    And if teams are being used:
    ```php
    $user->hasRole('admin', 'human-resources');
    $user->hasRole(['admin', 'regular'], 'human-resources');
    $user->hasRole(['admin', 'regular'], 'human-resources', true); // Will require all
    ```

- ### `public isA`
  Is the same as [hasRole](#public-hasrole).

- ### `public isAn`
  Is the same as [hasRole](#public-hasrole).

- ### `public hasPermission`
  - **Arguments:**
    - `$permission (string, int, Illuminate\Database\Eloquent\Model)`
    - `$team = null`
    - `$requireAll = false`
  - **Returns:** `bool`
  - **Usage:**

    Check if an user has some permission(s).
    ```php
    $user->hasPermission('edit-user');
    $user->hasPermission(['edit-user', 'create-user']);
    $user->hasPermission(['edit-user', 'create-user'], true); // Will require all
    ```

    And if teams are being used:
    ```php
    $user->hasPermission('edit-user', 'human-resources');
    $user->hasPermission(['edit-user', 'create-user'], 'human-resources');
    $user->hasPermission(['edit-user', 'create-user'], 'human-resources', true); // Will require all
    ```

- ### `public can`
  Is the same as [hasPermission](#public-haspermission).

- ### `public isAbleTo`
  Is the same as [hasPermission](#public-haspermission).

- ### `public ability`
  - **Arguments:**
    - `$roles (string, array)`
    - `$permissions (string, array)`
    - `$team = null`
    - `$options = array`
  - **Returns:** `bool|array`
  - **Usage:**

    Check if an user has some role(s) or/and permission(s).
    ```php
    $user->ability('admin', 'edit-user');
    $user->hasPermission(['admin', 'regular'], ['edit-user', 'create-user']);
    $user->hasPermission(
          ['admin', 'regular']
        , ['edit-user', 'create-user']
        , ['validate_all' => true]
    ); // Will require all
    ```

    And if teams are being used:
    ```php
    $user->ability('admin', 'edit-user', 'human-resources');
    $user->hasPermission(['admin', 'regular'], ['edit-user', 'create-user'], 'human-resources');
    $user->hasPermission(
          ['admin', 'regular']
        , ['edit-user', 'create-user']
        , 'human-resources'
        , ['validate_all' => true]
    ); // Will require all
    ```

## Role

## Permission

## Team<commit_msg>Add attach/detach role to api<commit_after>---
sidebarDepth: 2
---

# API

## User
* ### `public cachedRoles`
  - **Returns:** `Illuminate\Database\Eloquent\Collection|array`
  - **Usage:**

    Get the user cached roles. If the `laratrust.use_cache` is set to `true` it will return an array and if it set to `false` it will return a collection.

- ### `public cachedPermissions`
  - **Returns:** `Illuminate\Database\Eloquent\Collection|array`
  - **Usage:**

    Get the user cached permissions. If `laratrust.use_cache` is set to `true` it will return an array and if it set to `false` it will return a collection.

- ### `public roles`
  - **Returns:** `Illuminate\Database\Eloquent\Relations\MorphToMany`
  - **Usage:**

    Get the morph to many user relationship with the roles.

- ### `public rolesTeams`
  - **Returns:** `Illuminate\Database\Eloquent\Relations\MorphToMany|null`
  - **Usage:**

    Get the morph to many user relationship with the teams through the roles. If `laratrust.use_teams` is set to `false` it will return null.

- ### `public permissions`
  - **Returns:** `Illuminate\Database\Eloquent\Relations\MorphToMany`
  - **Usage:**

    Get the morph to many user relationship with the permissions.

- ### `public hasRole`
  - **Arguments:**
    - `$role (string, int, Illuminate\Database\Eloquent\Model)`
    - `$team = null`
    - `$requireAll = false`
  - **Returns:** `bool`
  - **Usage:**

    Check if an user has some role(s).
    ```php
    $user->hasRole('admin');
    $user->hasRole(['admin', 'regular']);
    $user->hasRole(['admin', 'regular'], true); // Will require all
    ```

    And if teams are being used:
    ```php
    $user->hasRole('admin', 'human-resources');
    $user->hasRole(['admin', 'regular'], 'human-resources');
    $user->hasRole(['admin', 'regular'], 'human-resources', true); // Will require all
    ```

- ### `public isA`
  Is the same as [hasRole](#public-hasrole).

- ### `public isAn`
  Is the same as [hasRole](#public-hasrole).

- ### `public hasPermission`
  - **Arguments:**
    - `$permission (string, int, Illuminate\Database\Eloquent\Model)`
    - `$team = null`
    - `$requireAll = false`
  - **Returns:** `bool`
  - **Usage:**

    Check if an user has some permission(s).
    ```php
    $user->hasPermission('edit-user');
    $user->hasPermission(['edit-user', 'create-user']);
    $user->hasPermission(['edit-user', 'create-user'], true); // Will require all
    ```

    And if teams are being used:
    ```php
    $user->hasPermission('edit-user', 'human-resources');
    $user->hasPermission(['edit-user', 'create-user'], 'human-resources');
    $user->hasPermission(['edit-user', 'create-user'], 'human-resources', true); // Will require all
    ```

- ### `public can`
  Is the same as [hasPermission](#public-haspermission).

- ### `public isAbleTo`
  Is the same as [hasPermission](#public-haspermission).

- ### `public ability`
  - **Arguments:**
    - `$roles (string, array)`
    - `$permissions (string, array)`
    - `$team = null`
    - `$options = array`
  - **Returns:** `bool|array`
  - **Usage:**

    Check if an user has some role(s) or/and permission(s).
    ```php
    $user->ability('admin', 'edit-user');
    $user->ability(['admin', 'regular'], ['edit-user', 'create-user']);
    $user->ability(
          ['admin', 'regular']
        , ['edit-user', 'create-user']
        , ['validate_all' => true]
    ); // Will require all
    ```

    And if teams are being used:
    ```php
    $user->ability('admin', 'edit-user', 'human-resources');
    $user->ability(['admin', 'regular'], ['edit-user', 'create-user'], 'human-resources');
    $user->ability(
          ['admin', 'regular']
        , ['edit-user', 'create-user']
        , 'human-resources'
        , ['validate_all' => true]
    ); // Will require all
    ```

- ### `public attachRole`
  - **Arguments:**
    - `$role (string, int, Illuminate\Database\Eloquent\Model)`
    - `$team = null`
  - **Returns:** `$this`
  - **Usage:**

    Attach a role to an user.
    ```php
    $user->attachRole('admin');
    ```

    And if teams are being used:
    ```php
    $user->attachRole('admin', 'human-resources');
    ```

- ### `public detachRole`
  - **Arguments:**
    - `$role (string, int, Illuminate\Database\Eloquent\Model)`
    - `$team = null`
  - **Returns:** `$this`
  - **Usage:**

    Detach a role to an user.
    ```php
    $user->detachRole('admin');
    ```

    And if teams are being used:
    ```php
    $user->detachRole('admin', 'human-resources');
    ```

## Role

## Permission

## Team
{'fraction_non_alphanumeric': 0.19443127962085308, 'fraction_numerical': 0.00023696682464454977, 'mean_word_length': 3.1663376110562687, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '883103', 'n_tokens_mistral': 2701, 'n_tokens_neox': 2715, 'n_words': 715}