app/Http/Controllers/CategoriesController.php
/**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\Categories  $category
     * @return \Illuminate\Http\Response
     */
Update the specified resource in storage.
Update the specified resource in storage .
public function update(Request $request, Categories $category)
    {
        $data=request()->validate([
            'name'=>'required|unique:categories,name',
            'categories_type'=>'',
            'categories_image'=>'required',
            'categories_title'=>'required',
            'categories_size'=>'',
            'button_name'=>'required',
            'button_icon'=>'required',
        ]);
        if (request('categories_image')){
            $imagePath = request('categories_image')->store('CategoriesImage', 'public');
            $image = Image::make("storage/{$imagePath}")->fit(350, 380);
            $data = array_merge($data,['categories_image'=>$imagePath]);
        }
        $category->update($data);
        return redirect('/categories');
    }
public function update ( Request $ request , Categories $ category ) { $ data = request ( ) -> validate ( [ 'name' => 'required|unique:categories,name' , 'categories_type' => '' , 'categories_image' => 'required' , 'categories_title' => 'required' , 'categories_size' => '' , 'button_name' => 'required' , 'button_icon' => 'required' , ] ) ; if ( request ( 'categories_image' ) ) { $ imagePath = request ( 'categories_image' ) -> store ( 'CategoriesImage' , 'public' ) ; $ image = Image :: make ( " storage/ { $ imagePath } " ) -> fit ( 350 , 380 ) ; $ data = array_merge ( $ data , [ 'categories_image' => $ imagePath ] ) ; } $ category -> update ( $ data ) ; return redirect ( '/categories' ) ; }
Update the specified resource in storage.
Update the specified resource in storage .