app/Http/Controllers/CategoryController.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)
    {
        $this->validate($request,[
            'name'       =>'required'
        ],[
            'name.required' =>'Category name required'
        ]);
        $cat = new Category();
        $cat->name = trim($request->input('name'));
        $cat->parent = trim($request->input('parent'));
        $cat->description = trim($request->input('description'));
        $cat->user_id = Auth::user()->id;
        $cat->active = 1;
        $cat->save();
    }
public function store ( Request $ request ) { $ this -> validate ( $ request , [ 'name' => 'required' ] , [ 'name.required' => 'Category name required' ] ) ; $ cat = new Category ( ) ; $ cat -> name = trim ( $ request -> input ( 'name' ) ) ; $ cat -> parent = trim ( $ request -> input ( 'parent' ) ) ; $ cat -> description = trim ( $ request -> input ( 'description' ) ) ; $ cat -> user_id = Auth :: user ( ) -> id ; $ cat -> active = 1 ; $ cat -> save ( ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .