app/Http/Controllers/Admin/CategoryController.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)
    {
         $this->validate($request,[
            'name' => 'required|min:3|max:50|unique:categories,name,'.$request->id,
            'status' => 'required',
     ]);
        $category = Category::find($request->id);
        $category->name = $request->name;
        $category->slug = slugify($request->name);
        $category->status = $request->status;
        if($category->save()){
        $success = true;
        }else{
            $success = false;
        }
        return response()->json(['success' => $success],200);
    }
public function update ( Request $ request ) { $ this -> validate ( $ request , [ 'name' => 'required|min:3|max:50|unique:categories,name,' . $ request -> id , 'status' => 'required' , ] ) ; $ category = Category :: find ( $ request -> id ) ; $ category -> name = $ request -> name ; $ category -> slug = slugify ( $ request -> name ) ; $ category -> status = $ request -> status ; if ( $ category -> save ( ) ) { $ success = true ; } else { $ success = false ; } return response ( ) -> json ( [ 'success' => $ success ] , 200 ) ; }
Update the specified resource in storage.
Update the specified resource in storage .
//Check Validation //Update database