app/Http/Controllers/TeamsController.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)
    {
        $team_name      = $request->input( 'teamName', false );
        $team_logo      = $request->input( 'teamLogo', false );
        $players_to_add = $request->input( 'freeAgents', false );
        $team = new Team;
        $team->team_name = $team_name;
        $team->team_logo = $team_logo;
        if ( $team->save() ) {
            foreach ( $players_to_add as $player_id ) {
                $team->players()->attach( $player_id );
            }
        }
        return redirect( '/project-1/teams' );
    }
public function store ( Request $ request ) { $ team_name = $ request -> input ( 'teamName' , false ) ; $ team_logo = $ request -> input ( 'teamLogo' , false ) ; $ players_to_add = $ request -> input ( 'freeAgents' , false ) ; $ team = new Team ; $ team -> team_name = $ team_name ; $ team -> team_logo = $ team_logo ; if ( $ team -> save ( ) ) { foreach ( $ players_to_add as $ player_id ) { $ team -> players ( ) -> attach ( $ player_id ) ; } } return redirect ( '/project-1/teams' ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .