本文整理匯總了PHP中app\Menu::createdby方法的典型用法代碼示例。如果您正苦於以下問題:PHP Menu::createdby方法的具體用法?PHP Menu::createdby怎麽用?PHP Menu::createdby使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類app\Menu
的用法示例。
在下文中一共展示了Menu::createdby方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
DB::transaction(function () use($request) {
//1. Validation
$this->validate($request, ['title' => 'required|unique:menu_translations', 'position' => 'required', 'type' => 'required', 'status' => 'required', 'parent_id' => 'numeric', 'ordering' => 'required|numeric']);
//2. GET ALL REQUESTS AND CREATE MENU OBJECT
$input = $request->all();
if ($request->input('parent_id') == '') {
$input = $request->except('parent_id');
} else {
$menuParent = Menu::find($request->input('parent_id'));
$input['level'] = ++$menuParent->level;
}
$menu = new Menu($input);
//3. SET CREATED USER TO THE MENU
$menu->updatedBy()->associate(Auth::user());
$menu->createdby()->associate(Auth::user());
//4. SAVE MENU
$menu->save();
//$menuTranslations = new MenuTranslation($request->all());
//$menu->menuTranslation()->save($menuTranslations);
//3. INSERT INTO MENUS TABLE
//Menu::create($input);
//Menu::fill($input)->save();
//5. FLASH MESSAGE BACK
Session::flash('flash_message', 'Menu successfully added!');
//6. REDIRECT BACK
});
return redirect()->back();
}