src/Http/Controllers/CmsCategoryController.php
/**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\CmsCategory  $category
     * @return \Illuminate\Http\Response
     */
Update the specified resource in storage.
Update the specified resource in storage .
public function update(Request $request, CmsCategory $category)
    {
        $validatedData = $request->validate([
            'name' => ['required', 'max:60', Rule::unique('cms_categories')->ignore($category->id)],
        ]);
        try {
            $category->update($validatedData);
            return redirect(route('posts.categories.index'))->with('status', 'category updated successfully');
        } catch (\Throwable $th) {
            return redirect()->back()->with('error', 'Something went wrong ' . $th->getMessage());
        }
    }
public function update ( Request $ request , CmsCategory $ category ) { $ validatedData = $ request -> validate ( [ 'name' => [ 'required' , 'max:60' , Rule :: unique ( 'cms_categories' ) -> ignore ( $ category -> id ) ] , ] ) ; try { $ category -> update ( $ validatedData ) ; return redirect ( route ( 'posts.categories.index' ) ) -> with ( 'status' , 'category updated successfully' ) ; } catch ( \ Throwable $ th ) { return redirect ( ) -> back ( ) -> with ( 'error' , 'Something went wrong ' . $ th -> getMessage ( ) ) ; } }
Update the specified resource in storage.
Update the specified resource in storage .