app/Http/Controllers/TeamController.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)
    {
        $this->authorize("create", Team::class);
        request()->validate([
            "photo"=>["required"],
            "nom"=>["required"],
            "statut"=>["required"]
        ]);
        $team = new Team();
        $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 store ( Request $ request ) { $ this -> authorize ( " create " , Team :: class ) ; request ( ) -> validate ( [ " photo " => [ " required " ] , " nom " => [ " required " ] , " statut " => [ " required " ] ] ) ; $ team = new Team ( ) ; $ team -> photo = $ request -> file ( 'img' ) -> hashName ( ) ; $ request -> file ( 'img' ) -> storePublicly ( 'img' , 'public' ) ; $ team -> nom = $ request -> nom ; $ team -> statut = $ request -> statut ; $ team -> save ( ) ; return redirect ( '/' ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .