app/Http/Controllers/FeatureController.php
/**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\Models\Feature  $feature
     * @return \Illuminate\Http\Response
     */
Update the specified resource in storage.
Update the specified resource in storage .
public function update(Request $request, Feature $feature)
    {
        $this->authorize("update", Feature::class);
        Storage::disk('public')->delete("assets/img/".$feature->image);
        $feature->image = $request->file("image");
        request()->validate([
            "image"=>["required"],
            "titre"=>["required"],
            "sous-titre"=>["required"],
            "description1"=>["required"],
            "description2"=>["required"],
            "description3"=>["required"]
        ]);
        $feature->titre = $request->titre;
        $feature->sous_titre = $request->sous_titre;
        $feature->description1 = $request->description1;
        $feature->description2 = $request->description2;
        $feature->description3 = $request->description3;
        $feature->save();
        $request->file("image")->storePublicly("img", "public");
        return redirect('/');
    }
public function update ( Request $ request , Feature $ feature ) { $ this -> authorize ( " update " , Feature :: class ) ; Storage :: disk ( 'public' ) -> delete ( " assets/img/ " . $ feature -> image ) ; $ feature -> image = $ request -> file ( " image " ) ; request ( ) -> validate ( [ " image " => [ " required " ] , " titre " => [ " required " ] , " sous-titre " => [ " required " ] , " description1 " => [ " required " ] , " description2 " => [ " required " ] , " description3 " => [ " required " ] ] ) ; $ feature -> titre = $ request -> titre ; $ feature -> sous_titre = $ request -> sous_titre ; $ feature -> description1 = $ request -> description1 ; $ feature -> description2 = $ request -> description2 ; $ feature -> description3 = $ request -> description3 ; $ feature -> save ( ) ; $ request -> file ( " image " ) -> storePublicly ( " img " , " public " ) ; return redirect ( '/' ) ; }
Update the specified resource in storage.
Update the specified resource in storage .