app/Http/Controllers/SubcategoriesController.php
/**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
Update the specified resource in storage.
Update the specified resource in storage .
public function update(Request $request, $id)
    {
        if(auth()->user()->isAdmin()){
            $this->validate($request,[
                'subcateg_name'=>'required',
            ]);
            $subcategory = Subcategory::find($id);
            if($subcategory === null) abort(404);
            $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 update ( Request $ request , $ id ) { if ( auth ( ) -> user ( ) -> isAdmin ( ) ) { $ this -> validate ( $ request , [ 'subcateg_name' => 'required' , ] ) ; $ subcategory = Subcategory :: find ( $ id ) ; if ( $ subcategory === null ) abort ( 404 ) ; $ subcategory -> name = $ request -> input ( 'subcateg_name' ) ; $ subcategory -> category_id = $ request -> input ( 'subcateg_category' ) ; $ subcategory -> save ( ) ; return redirect ( 'categories/' . $ subcategory -> category_id ) ; } else abort ( 404 ) ; }
Update the specified resource in storage.
Update the specified resource in storage .