1. Go to this page and download the library: Download rappasoft/vault 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/ */
namespace App;
...
use Illuminate\Database\Eloquent\SoftDeletes;
use Rappasoft\Vault\Traits\UserHasRole;
class User extends Model implements AuthenticatableContract, CanResetPasswordContract {
use Authenticatable, CanResetPassword, SoftDeletes, UserHasRole;
}
/*
* The company name used in the footer of the vault views.
*/
vault.general.company_name
/*
* Whether or not to load the vault views when the application loads.
* Useful if you want to copy the vault routes into your own routes file to modify.
*/
vault.general.use_vault_routes
/*
* The namespaced route to the vault role
*/
vault.role
/*
* The namespaced route to the vault permission
*/
vault.permission
/*
* Used by Vault to save roles to the database.
*/
vault.roles_table
/*
* Used by Vault to save permissions to the database.
*/
vault.permissions_table
/*
* Used by Vault to save relationship between permissions and roles to the database.
*/
vault.permission_role_table
/*
* Used by Vault to save relationship between permissions and users to the database.
* This table is only for permissions that belong directly to a specific user and not a role
*/
vault.permission_user_table
/*
* Used by Vault to save assigned roles to the database.
*/
vault.assigned_roles_table
/*
* Amount of users to show per page for pagination on users.index
*/
vault.users.default_per_page
/*
* The rules to validate the users password by when creating a new user
*/
vault.users.password_validation
/*
* Whether a role must contain a permission or can be used standalone (perhaps as a label)
*/
vault.roles.role_must_contain_permission
/*
* Whether or not the administrator role must possess every permission
* Works in unison with permissions.permission_must_contain_role
*/
vault.roles.administrator_forced
/*
* Whether a permission must contain a role or can be used standalone
* Works in unison with roles.administrator_forced
* If a permission doesn't contain a role it can be assigned directly to a user
*/
vault.permissions.permission_must_contain_role
/*
* Validation overwrites, at time of validation uses these rules
* Each must return an array even if a single rule
*/
vault.validation.users.create
vault.validation.users.update
if ($user->status == 0)
return Redirect::back()->withMessage("Your account is currently disabled");
Route::group([
'middleware' => 'vault.routeNeedsRole',
'role' => ['Administrator'],
'redirect' => '/',
'with' => ['error', 'You do not have access to do that.']
], function()
{
Route::group(['prefix' => 'access'], function ()
{
/*User Management*/
Route::resource('users', '\Rappasoft\Vault\Http\Controllers\UserController', ['except' => ['show']]);
});
});
/**
* Checks if the user has a Role by its name.
* @param string $name
* @return bool
*/
Vault::hasRole($role);
/**
* Checks to see if the user has an array of roles, and whether or not all must return true to authenticate
* @param array $roles
* @param boolean $needsAll
* @return bool
*/
Vault::hasRoles($roles, $needsAll);
/**
* Check if user has a permission by its name.
* @param string $permission.
* @return bool
*/
Vault::can($permission);
/**
* Check an array of permissions and whether or not all are
@role('User')
This content will only show if the authenticated user has the `User` role.
@endrole
@permission('can_view_this_content')
This content will only show if the authenticated user is somehow associated with the `can_view_this_content` permission.
@endpermission