app/Http/Controllers/News/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([
    		'title' => ['required', 'min:3'],
			'slug' => ['required' ,'min:3', Rule::unique('categories')->ignore($category->id)]
		]);
        $category->title = $request->input('title');
        $category->slug  = $request->input('slug');
        if($category->save()) {
			return redirect()->route('categories.index')
				->with('success', 'Категория успешно обновлена');
		}
        return back()->with('error', 'Не удалось обновить данные');
    }
public function update ( Request $ request , Category $ category ) { $ request -> validate ( [ 'title' => [ 'required' , 'min:3' ] , 'slug' => [ 'required' , 'min:3' , Rule :: unique ( 'categories' ) -> ignore ( $ category -> id ) ] ] ) ; $ category -> title = $ request -> input ( 'title' ) ; $ category -> slug = $ request -> input ( 'slug' ) ; if ( $ category -> save ( ) ) { return redirect ( ) -> route ( 'categories.index' ) -> with ( 'success' , 'Категория успешно обновлена'); } return back ( ) -> with ( 'error' , 'Не удалось обновить данные'); }
Update the specified resource in storage.
Update the specified resource in storage .