app/Http/Controllers/TestimonialController.php
/**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
Store a newly created resource in storage.
Store a newly created resource in storage .
public function store(Request $request)
    {
        $request->validate([
            "description" => ["required"],
            "photo" => ["required"],
            "nom" => ["required"],
            "statut" => ["required"]
        ]);
        $testimonial = new Testimonial;
        $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 store ( Request $ request ) { $ request -> validate ( [ " description " => [ " required " ] , " photo " => [ " required " ] , " nom " => [ " required " ] , " statut " => [ " required " ] ] ) ; $ testimonial = new Testimonial ; $ 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' ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .
// $this->authorize("create", Testimonial::class);