src/Http/Controllers/CmsMenuController.php
/**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
Store a newly created resource in storage.
Store a newly created resource in storage .
public function store(Request $request)
    {
        $validatedData = $request->validate([
            'name' => ['required', 'string', 'max:20'],
            'url' => ['required', 'url'],
        ]);
        try {
            if ($request->is_checked) {
                $validatedData['is_checked'] = true;
            }
            CmsMenu::create($validatedData);
            return redirect()->route('cms.menus.index')->with('message', 'menu added successfully');
        } catch (\Throwable $th) {
            return redirect()->back()->with('error', 'Something went wrong!. ' . $th->getMessage());
        }
    }
public function store ( Request $ request ) { $ validatedData = $ request -> validate ( [ 'name' => [ 'required' , 'string' , 'max:20' ] , 'url' => [ 'required' , 'url' ] , ] ) ; try { if ( $ request -> is_checked ) { $ validatedData [ 'is_checked' ] = true ; } CmsMenu :: create ( $ validatedData ) ; return redirect ( ) -> route ( 'cms.menus.index' ) -> with ( 'message' , 'menu added successfully' ) ; } catch ( \ Throwable $ th ) { return redirect ( ) -> back ( ) -> with ( 'error' , 'Something went wrong!. ' . $ th -> getMessage ( ) ) ; } }
Store a newly created resource in storage.
Store a newly created resource in storage .