本文整理汇总了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();
}