本文整理匯總了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');
}
}