PHP code example of rockbuzz / lara-memberships

1. Go to this page and download the library: Download rockbuzz/lara-memberships library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

rockbuzz / lara-memberships example snippets


$ php artisan vendor:publish --provider="Rockbuzz\LaraMemberships\ServiceProvider"

$ php artisan migrate

...
'rbac' => [
    /* 'admin' => [
        '*'
    ],
    'editor' => [
        '*.create',
        '*.update',
        'posts.delete'
    ] */
]

use Rockbuzz\LaraMemberships\Account;

class User
{
    use HasMemberships
}

$user->ownedAccounts(): HasMany;
$user->accounts(): BelongsToMany;
$user->allAccounts(): Collection;
$user->accountRole(Account $account): Role;
$user->hasAccountRole(Account $account, string $role): bool;
$user->accountPermissions($account): string[];
$user->hasAccountPermission(Account $account, string $permission): bool;
$user->ownsAccount(Account $account): bool;

$account->owner(): User;
$account->members(): BelongsToMany;
$account->findMemberById(int $id): User;
$account->addMember(User $user, Role $role = null): self;