本文整理匯總了PHP中app\Role::role方法的典型用法代碼示例。如果您正苦於以下問題:PHP Role::role方法的具體用法?PHP Role::role怎麽用?PHP Role::role使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類app\Role
的用法示例。
在下文中一共展示了Role::role方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: update
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id = null)
{
if (is_null($id)) {
$group = new Group();
} else {
$group = Group::findOrfail($id);
}
$group->designation = Input::get('designation');
$group->localization = Input::get('localization');
$group->creation_date = Input::get('creation_date');
$group->inactivation_date = Input::get('inactivation_date');
$group->save();
$years = Input::get('team_coordinator.years');
if (!is_null($years)) {
foreach ($years as $year) {
foreach (['coordinator' => 'Coordenador', 'secretary' => 'Secretario', 'treasurer' => 'Tesoureiro'] as $key => $value) {
$group->setRole(Role::role($value), $group->id, $year, (int) Input::get('team_coordinator.' . $year . '.' . $key . '.encontrista.id'));
}
}
}
return response()->json(['message' => is_null($id) ? 'Successfully created Group!' : 'Successfully updated Group!', 'group' => $group]);
}
示例2: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
factory(App\Encontrista::class, 50)->create()->each(function ($u) {
$u->roles()->create(['role_id' => Role::role('Encontrista'), 'group_id' => DB::table('groups')->orderBy(DB::raw('RAND()'))->get()[0]->id]);
});
}
示例3: getMembersAttribute
public function getMembersAttribute()
{
return $this->members()->whereRoleId(Role::role('Encontrista'))->get();
}