app/Http/Controllers/TeamsController.php
/**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
Show the form for creating a new resource.
@return \Illuminate\Http\Response
Show the form for creating a new resource . @return \ Illuminate \ Http \ Response
public function create()
    {
        $players = Player::with( 'team' )->get();
        $free_agents = [];
        foreach ( $players as $player ) {
            if ( count( $player->team ) < 1 ) {
                array_push( $free_agents, $player );
            }
        }
        $free_agent_collection = collect( $free_agents );
        return view( 'project1.createTeam', [
            'free_agents' => $free_agent_collection
        ]);
    }
public function create ( ) { $ players = Player :: with ( 'team' ) -> get ( ) ; $ free_agents = [ ] ; foreach ( $ players as $ player ) { if ( count ( $ player -> team ) < 1 ) { array_push ( $ free_agents , $ player ) ; } } $ free_agent_collection = collect ( $ free_agents ) ; return view ( 'project1.createTeam' , [ 'free_agents' => $ free_agent_collection ] ) ; }
Show the form for creating a new resource.
Show the form for creating a new resource .
// Find players without a team