本文整理汇总了PHP中Sentinel::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Sentinel::create方法的具体用法?PHP Sentinel::create怎么用?PHP Sentinel::create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sentinel
的用法示例。
在下文中一共展示了Sentinel::create方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
//get the persons details
$staff = Staff::find($request->user);
$data = ['email' => $staff->email];
// var_dump($data);
// dd($data);
$rules = ['email' => 'min:5|email|required|unique:users'];
$validator = \Validator::make($data, $rules);
if ($validator->passes()) {
// dd($staff->id);
//array to hold final permission values
$array_of_permissions = Helper::prepPermissions($request->exempt_permission, 'false');
$credentials = ['email' => $staff->email, 'password' => $request->password, 'permissions' => $array_of_permissions, 'staff_id' => $staff->id, 'first_name' => $staff->fname, 'last_name' => $staff->lname];
//create new user
$user = \Sentinel::create($credentials);
//activate user
$activation = \Activation::create($user);
$activation_completed = \Activation::complete($user, $activation->code);
//assign new user to role(s)
$user = \Sentinel::findById($user->id);
foreach ($request->assign_roles as $role_id) {
$role = \Sentinel::findRoleById($role_id);
$role->users()->attach($user);
}
return \Redirect::to('settings/users/create');
} else {
return \Redirect::back()->withInput()->withErrors($validator);
}
}
示例2: run
public function run()
{
try {
$role = \Sentinel::findRoleByName('Administrator');
$credentials = ['email' => 'admin@soa.backend', 'password' => 'password'];
$user = \Sentinel::create($credentials);
$role->users()->attach($user);
$activation = \Activation::create($user);
$activation_complete = \Activation::complete($user, $activation->code);
} catch (\Exception $e) {
}
}
示例3: run
public function run()
{
try {
$role = \Sentinel::getRoleRepository()->createModel()->create(['name' => 'Administrator', 'slug' => 'administrator']);
$role = \Sentinel::findRoleByName('Administrator');
$role->permissions = ['superadmin' => true, 'controlpanel' => true, 'admin.users.view' => true, 'admin.users.create' => true, 'admin.users.edit' => true, 'admin.users.destroy' => true, 'admin.roles.view' => true, 'admin.roles.create' => true, 'admin.roles.edit' => true, 'admin.roles.destroy' => true];
$role->save();
$credentials = ['email' => 'admin@soa.backend', 'password' => 'password'];
$user = \Sentinel::create($credentials);
$role->users()->attach($user);
$activation = \Activation::create($user);
$activation_complete = \Activation::complete($user, $activation->code);
} catch (\Exception $e) {
}
}
示例4: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
DB::table('users')->truncate();
//truncate roles
DB::table('roles')->truncate();
//truncate role_users
DB::table('role_users')->truncate();
$credentials = ['email' => 'umahatokula@ovalsofttechnologies.com', 'password' => 'come', 'first_name' => 'Umaha', 'last_name' => 'Tokula'];
//create new user
$user = \Sentinel::create($credentials);
$activation = \Activation::create($user);
$activation_completed = \Activation::complete($user, $activation->code);
//create coder role
$coder = Sentinel::getRoleRepository()->createModel()->create(['name' => 'Coder', 'slug' => 'coder']);
//assign user this role
$coder->users()->attach($user);
//create principal role
$principal = Sentinel::getRoleRepository()->createModel()->create(['name' => 'Principal', 'slug' => 'principal']);
//assign user this role
$principal->users()->attach($user);
//create head teacher role
$head_teacher = Sentinel::getRoleRepository()->createModel()->create(['name' => 'Class Teacher', 'slug' => 'head_teacher']);
//assign user this role
$head_teacher->users()->attach($user);
//create billing officer role
$billing_officer = Sentinel::getRoleRepository()->createModel()->create(['name' => 'Billing Officer', 'slug' => 'billing_officer']);
//assign user this role
$billing_officer->users()->attach($user);
//create admin dept officer role
$admin_dept_officer = Sentinel::getRoleRepository()->createModel()->create(['name' => 'Admin Dept Officer', 'slug' => 'admin_dept_officer']);
//assign user this role
$admin_dept_officer->users()->attach($user);
//create accounts officer role
$accounts_officer = Sentinel::getRoleRepository()->createModel()->create(['name' => 'Accounts Officer', 'slug' => 'accounts_officer']);
//assign user this role
$accounts_officer->users()->attach($user);
}
示例5: sprintf
|--------------------------------------------------------------------------
|
*/
/*
|--------------------------------------------------------------------------
| Auth 2. Touch auth file
|--------------------------------------------------------------------------
|
*/
case 'authtouch':
if (Sentinel::isAuthSet() === true) {
$path = Sentinel::getAuthFilePath();
$return['notice'] = sprintf(__('File <code>%s</code> already exists!'), AUTH_CONFIGURATION_FILE) . '<br/><br/>' . __('Please remove it from the root directory:') . '<div class="row">' . ' <div class="col-md-10"><pre class="clipboardcontent">' . 'mv \'' . $path . '\' \'' . $path . '.bck\'</pre></div>' . ' <div class="col-md-2"><a class="btn btn-primary clipboard">' . __('Copy to clipboard') . '</a><script>clipboard_enable("a.clipboard","pre.clipboardcontent" , "top" , "' . __('Command copied!') . '");</script></div>' . '</div>';
$return['reload'] = true;
} else {
if (Sentinel::create() === true) {
$return['authform'] = '<h2>' . __('Setup admin account') . '</h2>' . '<br/>' . __('Please choose a username and a password for the admin account.') . '<br/><br/>' . '<form id="authsave" autocomplete="off">' . '<div class="container">' . '<div class="row">' . '<div class="input-group col-sm-6 col-md-4" id="usernamegroup" data-toggle="tooltip" data-placement="top" title="' . htmlentities(__('Username is required')) . '">
<span class="input-group-addon"><span class="glyphicon glyphicon-user"></span></span>
<input type="text" id="username" class="form-control" placeholder="' . __('Username') . '" autofocus="autofocus">
</div>' . '<br/>' . '</div>' . '<div class="row">' . '<div class="input-group col-sm-6 col-md-4" id="passwordgroup" data-toggle="tooltip" data-placement="bottom" title="' . htmlentities(__('Password must contain at least 6 chars')) . '">
<span class="input-group-addon"><span class="glyphicon glyphicon-lock"></span></span>
<input type="password" id="password" class="form-control" placeholder="' . __('Password') . '">
</div>' . '<br/>' . '</div>' . '<div class="row">' . '<div class="input-group col-sm-6 col-md-4" id="password2group" data-toggle="tooltip" data-placement="bottom" title="' . htmlentities(__('Password is not the same')) . '">
<span class="input-group-addon"><span class="glyphicon glyphicon-lock"></span></span>
<input type="password" id="password2" class="form-control" placeholder="' . __('Password Confirmation') . '">
</div>' . '</div>' . '</div>' . '<br/><br/>' . '<input type="submit" class="btn btn-primary" value="' . __('Continue') . '"/>' . '</form>';
} else {
$return['notice'] = '<div class="alert alert-danger">' . sprintf(__('Unable to create file <code>%s</code>'), AUTH_CONFIGURATION_FILE) . '</div>' . __('Please give temporary write access to the root directory:') . '<div class="row">' . ' <div class="col-md-10"><pre class="clipboardcontent">' . 'chmod 777 ' . dirname(dirname(__FILE__)) . '</pre></div>' . ' <div class="col-md-2"><a class="btn btn-primary clipboard">' . __('Copy to clipboard') . '</a><script>clipboard_enable("a.clipboard","pre.clipboardcontent" , "top" , "' . __('Command copied!') . '");</script></div>' . '</div>';
$return['reload'] = true;
}
}
示例6:
<?php
# Create a default admin user
include 'inc/global.inc.php';
include 'inc/classes/Sentinel.php';
Sentinel::init();
Sentinel::create();
$username = $_ENV['SYSLOG_USERNAME'];
$password = $_ENV['SYSLOG_PASSWORD'];
echo "Creating user with credentials: {$username}:{$password}\n";
Sentinel::setAdmin($username, $password);
Sentinel::save();
示例7: function
<?php
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
Route::get('/', function () {
$credentials = ['email' => 'john.doe@example.com', 'password' => 'password'];
$user = Sentinel::create($credentials);
return $user;
});
示例8: createAdminUserAndRole
protected function createAdminUserAndRole()
{
$permissions = ['superadmin' => ['default' => true, 'description' => 'Super Admin'], 'controlpanel' => ['default' => true, 'description' => 'Access to the Control Panel'], 'admin.users.view' => ['default' => true, 'description' => 'View Users'], 'admin.users.create' => ['default' => true, 'description' => 'Create Users'], 'admin.users.edit' => ['default' => true, 'description' => 'Edit Users'], 'admin.users.destroy' => ['default' => true, 'description' => 'Delete Users'], 'admin.roles.view' => ['default' => true, 'description' => 'View Roles'], 'admin.roles.create' => ['default' => true, 'description' => 'Create Roles'], 'admin.roles.edit' => ['default' => true, 'description' => 'Edit Roles'], 'admin.roles.destroy' => ['default' => true, 'description' => 'Delete Roles'], 'admin.permissions.view' => ['default' => true, 'description' => 'View Permissions'], 'admin.permissions.create' => ['default' => true, 'description' => 'Create Permissions'], 'admin.permissions.edit' => ['default' => true, 'description' => 'Edit Permissions'], 'admin.permissions.destroy' => ['default' => true, 'description' => 'Delete Permissions']];
try {
//create admin user
$credentials = ['email' => 'admin@soa.backend', 'password' => 'password'];
$user = \Sentinel::create($credentials);
$activation = \Activation::create($user);
$activation_complete = \Activation::complete($user, $activation->code);
//create admin role
$role = \Sentinel::getRoleRepository()->createModel()->create(['name' => 'Administrator', 'slug' => 'administrator']);
$role = \Sentinel::findRoleByName('Administrator');
//add permissions to role
foreach ($permissions as $key => $permission) {
$role->addPermission($key, $permission['default']);
}
$role->save();
//attach admin user to admin role
$role->users()->attach($user);
$this->info('Admin Role and User created successfully.');
$this->addPermissions($permissions);
} catch (\Exception $e) {
$this->info('Something went wrong while creating Admin Role and User.');
$this->error($e);
}
}
示例9: createAdminUserAndRole
protected function createAdminUserAndRole()
{
try {
$role = \Sentinel::getRoleRepository()->createModel()->create(['name' => 'Administrator', 'slug' => 'administrator']);
$role = \Sentinel::findRoleByName('Administrator');
$role->permissions = ['superadmin' => true, 'controlpanel' => true, 'admin.users.view' => true, 'admin.users.create' => true, 'admin.users.edit' => true, 'admin.users.destroy' => true, 'admin.roles.view' => true, 'admin.roles.create' => true, 'admin.roles.edit' => true, 'admin.roles.destroy' => true];
$role->save();
$credentials = ['email' => 'admin@soa.backend', 'password' => 'password'];
$user = \Sentinel::create($credentials);
$role->users()->attach($user);
$activation = \Activation::create($user);
$activation_complete = \Activation::complete($user, $activation->code);
$this->info('Admin Role and User created successfully.');
} catch (\Exception $e) {
$this->info('Something went wrong while creating Admin Role and User.');
}
}