app/Http/Controllers/TestimonialController.php
/**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\Models\Testimonial  $testimonial
     * @return \Illuminate\Http\Response
     */
Update the specified resource in storage.
Update the specified resource in storage .
public function update(Request $request, Testimonial $testimonial)
    {
        $this->authorize("update", Testimonial::class);
        $request->validate([
            "description" => ["required"],
            "photo" => ["required"],
            "nom" => ["required"],
            "statut" => ["required"]
        ]);
        Storage::disk("public")->delete("img/" . $testimonial->photo);
        $testimonial->description = $request->description;
        $testimonial->photo= $request->file("photo")->hashName();
        $testimonial->nom = $request->nom;
        $testimonial->statut = $request->statut;
        $request->file("photo")->storePublicly("img", "public");
        $testimonial->save();
        return redirect()->route('testimonials.index');
    }
public function update ( Request $ request , Testimonial $ testimonial ) { $ this -> authorize ( " update " , Testimonial :: class ) ; $ request -> validate ( [ " description " => [ " required " ] , " photo " => [ " required " ] , " nom " => [ " required " ] , " statut " => [ " required " ] ] ) ; Storage :: disk ( " public " ) -> delete ( " img/ " . $ testimonial -> photo ) ; $ testimonial -> description = $ request -> description ; $ testimonial -> photo = $ request -> file ( " photo " ) -> hashName ( ) ; $ testimonial -> nom = $ request -> nom ; $ testimonial -> statut = $ request -> statut ; $ request -> file ( " photo " ) -> storePublicly ( " img " , " public " ) ; $ testimonial -> save ( ) ; return redirect ( ) -> route ( 'testimonials.index' ) ; }
Update the specified resource in storage.
Update the specified resource in storage .