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)
    {
        $this->validate($request, [
            'name' => 'required|unique:categories,name,'. $category->id
        ]);
        $data = $request->only('name');
        $data['slug'] = Str::slug($request->name);
        $category->update($data);
        return redirect()->route('category.index')
            ->with([
                'message' => 'Kategori berhasil diperbarui',
                'success' => true,
            ]);
    }
public function update ( Request $ request , Category $ category ) { $ this -> validate ( $ request , [ 'name' => 'required|unique:categories,name,' . $ category -> id ] ) ; $ data = $ request -> only ( 'name' ) ; $ data [ 'slug' ] = Str :: slug ( $ request -> name ) ; $ category -> update ( $ data ) ; return redirect ( ) -> route ( 'category.index' ) -> with ( [ 'message' => 'Kategori berhasil diperbarui' , 'success' => true , ] ) ; }
Update the specified resource in storage.
Update the specified resource in storage .