app/Http/Controllers/CategoryController.php
/**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\Models\Category  $category
     * @return \Illuminate\Http\Response
     */
Update the specified resource in storage.
Update the specified resource in storage .
public function update(Request $request,Category  $category)
    {   
        $request->validate([
            'category_name' => 'unique:categories,category_name,' . $request->id,
            'slug' => ['required'],
        ]);
        $category->category_name = $request->category_name;
        $category->slug = Str::slug($request->slug);
        $category->save();
        return back()->with('success','Category Updated Successfully');
    }
public function update ( Request $ request , Category $ category ) { $ request -> validate ( [ 'category_name' => 'unique:categories,category_name,' . $ request -> id , 'slug' => [ 'required' ] , ] ) ; $ category -> category_name = $ request -> category_name ; $ category -> slug = Str :: slug ( $ request -> slug ) ; $ category -> save ( ) ; return back ( ) -> with ( 'success' , 'Category Updated Successfully' ) ; }
Update the specified resource in storage.
Update the specified resource in storage .