本文整理汇总了PHP中app\Role::danhmuchucnangs方法的典型用法代码示例。如果您正苦于以下问题:PHP Role::danhmuchucnangs方法的具体用法?PHP Role::danhmuchucnangs怎么用?PHP Role::danhmuchucnangs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Role
的用法示例。
在下文中一共展示了Role::danhmuchucnangs方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store(Request $request)
{
if (Auth::check() && $this->rolechucnangs && $this->rolechucnangs->Them == 1) {
$role = new Role();
$role->name = $request->input('name');
$role->slug = $request->input('name');
$role->description = $request->input('description');
$role->save();
$id = $role->id;
//echo $id;
$xem = $request->input('xem');
$them = $request->input('them');
$xoa = $request->input('xoa');
$sua = $request->input('sua');
$chucnang = $request->input('chucnang');
if ($chucnang != NULL) {
$role->danhmuchucnangs()->sync($chucnang);
}
// cap nhat lại role moi
if (count($xem) > 0) {
foreach ($xem as $key => $value) {
\DB::table('role_chucnangs')->where('danhmucchucnang_id', $value)->where('role_id', $id)->update(['Xem' => 1]);
}
}
if (count($them) > 0) {
foreach ($them as $key => $value) {
\DB::table('role_chucnangs')->where('danhmucchucnang_id', $value)->where('role_id', $id)->update(['Them' => 1]);
}
}
if (count($xoa) > 0) {
foreach ($xoa as $key => $value) {
\DB::table('role_chucnangs')->where('danhmucchucnang_id', $value)->where('role_id', $id)->insert(['Xoa' => 1]);
}
}
if (count($sua) > 0) {
foreach ($sua as $key => $value) {
\DB::table('role_chucnangs')->where('danhmucchucnang_id', $value)->where('role_id', $id)->update(['Sua' => 1]);
}
}
if (count($chucnang) > 0) {
foreach ($chucnang as $key => $value) {
\DB::table('role_chucnangs')->where('danhmucchucnang_id', $value)->where('role_id', $id)->update(['Danhsach' => 1]);
}
}
return \Redirect::route('role.index')->with('message', 'Nhập thành công!');
} else {
return \Redirect::route('role.index')->with('message-error', 'Không có quyền truy cập');
}
}