本文整理汇总了PHP中Role::attachPermission方法的典型用法代码示例。如果您正苦于以下问题:PHP Role::attachPermission方法的具体用法?PHP Role::attachPermission怎么用?PHP Role::attachPermission使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Role
的用法示例。
在下文中一共展示了Role::attachPermission方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: up
/**
* Run the migrations.
*/
public function up()
{
// Creates the users table
Schema::create('users', function ($table) {
$table->increments('id');
$table->string('username')->unique();
$table->string('email')->unique();
$table->string('password');
$table->string('confirmation_code');
$table->string('remember_token')->nullable();
$table->boolean('confirmed')->default(false);
$table->timestamps();
});
// Creates password reminders table
Schema::create('password_reminders', function ($table) {
$table->string('email');
$table->string('token');
$table->timestamp('created_at');
});
$admin = new Role();
$admin->name = 'Admin';
$admin->save();
$user = new Role();
$user->name = 'User';
$user->save();
$read = new Permission();
$read->name = 'can_read';
$read->display_name = 'Can Read Data';
$read->save();
$edit = new Permission();
$edit->name = 'can_edit';
$edit->display_name = 'Can Edit Data';
$edit->save();
$user->attachPermission($read);
$admin->attachPermission($read);
$admin->attachPermission($edit);
// print_r($userRole);
// die();
$user1 = User::where('username', '=', 'admin')->first();
$user1->roles()->attach($admin);
$user2 = User::where('username', '!=', 'admin')->first();
$user2->roles()->attach($user);
return Redirect::action('home');
}
示例2: Permission
$user->name = 'User';
$user->save();
$read = new Permission();
$read->name = 'can_see';
$read->display_name = 'Can See User Profiles';
$read->save();
$edit = new Permission();
$edit->name = 'can_see_compatability';
$edit->display_name = 'Can See Compatability';
$edit->save();
$admin_p = new Permission();
$admin_p->name = 'admin';
$admin_p->display_name = 'Can Control Anything';
$admin_p->save();
$admin->attachPermission($admin_p);
$verified->attachPermission($read);
$verified->attachPermission($edit);
$user1 = \User::find(1);
$user2 = \User::find(2);
$user1->attachRole($admin);
$user2->attachRole($verified);
return 'Woohoo!';
});
Route::resource('users', 'UsersController');
Route::resource('users/{username}/about_your_date', 'AboutYourDateController');
Route::controller('deploy', 'ServerController');
Route::controller('users/{username}/compatability', 'CompatabilityController');
Route::controller('users/{username}/verify', 'VerifyController');
Route::group(array('before' => 'admin'), function () {
Route::resource('admin/slide', 'SlideManagementController');
Route::resource('admin/events', 'EventManagementController');
示例3: Role
$subscriber = new Role();
$subscriber->name = 'Subscriber';
$subscriber->save();
$author = new Role();
$author->name = 'Author';
$author->save();
$read = new Permission();
$read->name = 'can_read';
$read->display_name = 'Can Read Posts';
$read->save();
$edit = new Permission();
$edit->name = 'can_edit';
$edit->display_name = 'Can Edit Posts';
$edit->save();
$subscriber->attachPermission($read);
$author->attachPermission($read);
$author->attachPermission($edit);
$user1 = User::find(1);
$user2 = User::find(2);
$user1->attachRole($subscriber);
$user2->attachRole($author);
return 'Woohoo!';
});
Route::get('/secret', function () {
Auth::loginUsingId(1);
$user = Auth::user();
if ($user->hasRole('Author')) {
return 'Redheads party the hardest!';
}
return 'Many people like to party.';
});
示例4: run
//.........这里部分代码省略.........
$can_edit_years->name = 'can_edit_years';
$can_edit_years->display_name = 'can_edit_years';
$can_edit_years->description = 'can_edit_years';
$can_edit_years->save();
$can_edit_periodos = new Permission();
$can_edit_periodos->id = 9;
$can_edit_periodos->name = 'can_edit_periodos';
$can_edit_periodos->display_name = 'can_edit_periodos';
$can_edit_periodos->description = 'can_edit_periodos';
$can_edit_periodos->save();
$can_edit_paises = new Permission();
$can_edit_paises->id = 10;
$can_edit_paises->name = 'can_edit_paises';
$can_edit_paises->display_name = 'can_edit_paises';
$can_edit_paises->description = 'can_edit_paises';
$can_edit_paises->save();
$can_edit_ciudades = new Permission();
$can_edit_ciudades->id = 11;
$can_edit_ciudades->name = 'can_edit_ciudades';
$can_edit_ciudades->display_name = 'can_edit_ciudades';
$can_edit_ciudades->description = 'can_edit_ciudades';
$can_edit_ciudades->save();
$can_edit_disciplinas = new Permission();
$can_edit_disciplinas->id = 12;
$can_edit_disciplinas->name = 'can_edit_disciplinas';
$can_edit_disciplinas->display_name = 'can_edit_disciplinas';
$can_edit_disciplinas->description = 'can_edit_disciplinas';
$can_edit_disciplinas->save();
$can_edit_profesores = new Permission();
$can_edit_profesores->id = 13;
$can_edit_profesores->name = 'can_edit_profesores';
$can_edit_profesores->display_name = 'can_edit_profesores';
$can_edit_profesores->description = 'can_edit_profesores';
$can_edit_profesores->save();
$can_edit_eventos = new Permission();
$can_edit_eventos->id = 14;
$can_edit_eventos->name = 'can_edit_eventos';
$can_edit_eventos->display_name = 'can_edit_eventos';
$can_edit_eventos->description = 'can_edit_eventos';
$can_edit_eventos->save();
$can_edit_votaciones = new Permission();
$can_edit_votaciones->id = 15;
$can_edit_votaciones->name = 'can_edit_votaciones';
$can_edit_votaciones->display_name = 'can_edit_votaciones';
$can_edit_votaciones->description = 'can_edit_votaciones';
$can_edit_votaciones->save();
$can_edit_aspiraciones = new Permission();
$can_edit_aspiraciones->id = 16;
$can_edit_aspiraciones->name = 'can_edit_aspiraciones';
$can_edit_aspiraciones->display_name = 'can_edit_aspiraciones';
$can_edit_aspiraciones->description = 'can_edit_aspiraciones';
$can_edit_aspiraciones->save();
$can_edit_participantes = new Permission();
$can_edit_participantes->id = 17;
$can_edit_participantes->name = 'can_edit_participantes';
$can_edit_participantes->display_name = 'can_edit_participantes';
$can_edit_participantes->description = 'can_edit_participantes';
$can_edit_participantes->save();
$can_edit_candidatos = new Permission();
$can_edit_candidatos->id = 18;
$can_edit_candidatos->name = 'can_edit_candidatos';
$can_edit_candidatos->display_name = 'can_edit_candidatos';
$can_edit_candidatos->description = 'can_edit_candidatos';
$can_edit_candidatos->save();
$can_edit_unidades = new Permission();
$can_edit_unidades->id = 19;
$can_edit_unidades->name = 'can_edit_unidades_subunidades';
$can_edit_unidades->display_name = 'can_edit_unidades_subunidades';
$can_edit_unidades->description = 'can_edit_unidades_subunidades';
$can_edit_unidades->save();
$Profesor->attachPermission($perm_teacher);
$Alumno->attachPermission($perm_student);
$Acudiente->attachPermission($perm_acud);
$Manager->attachPermission($accept_img);
$Manager->attachPermission($can_edit_alumnos);
$Manager->attachPermission($can_edit_usuarios);
$Manager->attachPermission($can_edit_notas);
$Manager->attachPermission($can_edit_years);
$Manager->attachPermission($can_edit_periodos);
$Manager->attachPermission($can_edit_paises);
$Manager->attachPermission($can_edit_ciudades);
$Manager->attachPermission($can_edit_disciplinas);
$Manager->attachPermission($can_edit_profesores);
$Manager->attachPermission($can_edit_eventos);
$Manager->attachPermission($can_edit_votaciones);
$Manager->attachPermission($can_edit_aspiraciones);
$Manager->attachPermission($can_edit_participantes);
$Manager->attachPermission($can_edit_candidatos);
$Manager->attachPermission($can_edit_unidades);
//$Asistente->attachPermission($see_panel);
/*
$Alumno->attachPermission($print);
$user1 = User::find(1);
$user2 = User::find(2);
$user1->attachRole($Profesor);
$user2->attachRole($Alumno);
*/
}