app/Http/Controllers/Backend/BackendCategoryController.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)
    {
         Set some rules, I Set here because are only few rows
        $this->validate( $request, [
            'name' => 'required|max:250',
            'parent_id' => 'required|numeric|min:0',
        ]);
        Recovery input data
        $input_data = $request->all();
         Create new category
        $new_category = $this->categories->create($input_data);
        if ($new_category) {
                  Create new insert in pivot table
                $seo_data = $new_category->seo()->create($input_data);
                $new_category->seo()->save($seo_data);
            \Session::flash('flash_message_success', 'Success! Entry saved.');
        }else{
            \Session::flash('flash_message_error', 'Error! Entry Not saved.');
        }
         Return to list Category page
        return redirect()->route('categories.index');
    }
public function store ( Request $ request ) { $ this -> validate ( $ request , [ 'name' => 'required|max:250' , 'parent_id' => 'required|numeric|min:0' , ] ) ; $ input_data = $ request -> all ( ) ; $ new_category = $ this -> categories -> create ( $ input_data ) ; if ( $ new_category ) { $ seo_data = $ new_category -> seo ( ) -> create ( $ input_data ) ; $ new_category -> seo ( ) -> save ( $ seo_data ) ; \ Session :: flash ( 'flash_message_success' , 'Success! Entry saved.' ) ; } else { \ Session :: flash ( 'flash_message_error' , 'Error! Entry Not saved.' ) ; } return redirect ( ) -> route ( 'categories.index' ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .
// // Set some rules, I Set here because are only few rows //Recovery input data // Create new category //  Create new insert in pivot table // Return to list Category page