app/Http/Controllers/SubcategoriesController.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)
    {
        if(auth()->user()->isAdmin()){
            $this->validate($request,[
                'subcateg_name'=>'required',
            ]);
            $subcategory = new Subcategory;
            $subcategory->name = $request->input('subcateg_name');
            $subcategory->category_id = $request->input('subcateg_category');
            $subcategory->save();
            return redirect('categories/'.$subcategory->category_id);
        }
        else abort(404);
    }
public function store ( Request $ request ) { if ( auth ( ) -> user ( ) -> isAdmin ( ) ) { $ this -> validate ( $ request , [ 'subcateg_name' => 'required' , ] ) ; $ subcategory = new Subcategory ; $ subcategory -> name = $ request -> input ( 'subcateg_name' ) ; $ subcategory -> category_id = $ request -> input ( 'subcateg_category' ) ; $ subcategory -> save ( ) ; return redirect ( 'categories/' . $ subcategory -> category_id ) ; } else abort ( 404 ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .
// Create subcategory