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