PHP code example of fr3ddy / laratoor

1. Go to this page and download the library: Download fr3ddy/laratoor library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

fr3ddy / laratoor example snippets


    composer 

    Fr3ddy\Laratoor\LaratoorServiceProvider::class

    TOORNAMENT_KEY=
    TOORNAMENT_CLIENT_ID=
    TOORNAMENT_CLIENT_SECRET=

    use Fr3ddy\Laratoor\ViewerApi;

    $viewer = new ViewerApi();
    
    $discipline = $viewer->getDiscipline($id);
    $filter = array(
        'is_featured' => 1, //returns matches of featured tournaments
        'statuses' => [ //pass an array of status you want to have in your list
            'pending',
            'running'
        ]
    );
    $matches = $discipline->getAllMatches($filter);

    use Fr3ddy\Laratoor\ViewerApi;

    $viewer = new ViewerApi();
    
    //Collection of all disciplines
    $disciplines = $viewer->getAllDisciplines();
    //Collection of disciplines with pagination
    $disciplines = $viewer->getDisciplines($from,$to);
    //Discipline without platforms_available & team_size
    $first_discipline = $disciplines->first();
    //Discipline with platforms_available & team_size
    $first_discipline->loadDetails();
    //Discipline with platforms_available & team_size
    $discipline = $viewer->getDiscipline($id);
    //All Matches of this discipline
    $matches = $discipline->getAllMatches($filter);
    //Matches of this discipline with Pagination
    $matches = $discipline->getMatches($filter,$from,$to);

    use Fr3ddy\Laratoor\ViewerApi;

    $viewer = new ViewerApi();
    
    //Collection of all featured tournaments with filter
    $tournaments = $viewer->getAllFeaturedTournaments($filter);
    //Collection of featured tournaments with filter and pagination
    $tournaments = $viewer->getFeaturedTournaments($filter,$from,$to);
    //Tournament by Tournamnet ID
    $tournament = $viewer->getTournament($tournament_id);


    //Custom Fields of Teams for this tournament
    $custom_fields_team = $tournament->getCustomFieldsTeam();
    //Custom Fields of Team Players for this tournament
    $custom_fields_teamplayer = $tournament->getCustomFieldsTeamPlayer();
    //Custom Fields of Players for this tournament
    $custom_fields_player = $tournament->getCustomFieldsPlayer(); 

    use Fr3ddy\Laratoor\ViewerApi;

    $viewer = new ViewerApi();

    //By Tournament
    $tournament = $viewer->getTournament($tournament_id);
    //All Participants of this tournament with filter
    $participants = $tournament->getAllParticipants($filter);
    //Participants of this tournament with pagination
    $participants = $tournament->getParticipants($filter,$from,$to);
    //Participant of this tournament
    $participant = $tournament->getParticipant($participant_id);

    //By Tournamnet Id
    //All Participants of this tournament with filter
    $participants = $viewer->getAllParticipantsOfTournament($tournament_id,$filter);
    //Participants of this tournament with pagination
    $participants = $viewer->getParticipantsOfTournament($tournament_id,$filter,$from,$to);
    //Participant of this tournament
    $participant = $viewer->getParticipantOfTournament($tournament_id,$participant_id);

    use Fr3ddy\Laratoor\ViewerApi;

    $viewer = new ViewerApi();
    
    //By Tournament
    $tournament = $viewer->getTournament($tournament_id);
    //All Stages of this tournament
    $stages = $tournament->getStages();
    //Details of this Stage of this tournament
    $stage = $tournament->getStage($stage_id);

    //By Tournament ID
    //All Stages of this tournament
    $stages = $viewer->getStagesOfTournament($tournament_id);
    //Details of this Stage of this tournament
    $stage = $viewer->getStageOfTournament($tournament_id,$stage_id);

    use Fr3ddy\Laratoor\ViewerApi;

    $viewer = new ViewerApi();
    
    //By Tournament
    $tournament = $viewer->getTournament($tournament_id);
    //All Groups of this tournament with filter
    $groups = $tournament->getAllGroups($filter);
    //Groups of this tournament with filter and pagination
    $groups = $tournament->getGroups($filter,$from,$to);
    //Group details of this group of the specific tournament
    $group = $tournament->getGroup($group_id);

    //By Tournament ID
    //All Groups of this tournament with filter
    $groups = $viewer->getAllGroupsOfTournament($tournament_id,$filter);
    //Groups of this tournament with filter and pagination
    $groups = $viewer->getGroupsOfTournament($tournament_id,$filter,$from,$to);
    //Group details of this group of the specific tournament
    $group = $viewer->getGroupOfTournament($tournament_id,$group_id);

    use Fr3ddy\Laratoor\ViewerApi;

    $viewer = new ViewerApi();
    
    //By Tournament
    $tournament = $viewer->getTournament($tournament_id);
    //Get all Round for this tournament
    $rounds = $tournament->getAllRounds($filter);
    //Get Rounds with pagination for this tournament
    $rounds = $tournament->getRounds($filter,$from,$to);
    //Get Round details
    $round = $tournament->getRound($round_id);

    //By Tournament ID
    //Get all Round for this tournament
    $rounds = $viewer->getAllRoundsOfTournament($tournament_id,$filter);
    //Get Rounds with pagination for this tournament
    $rounds = $viewer->getRoundsOfTournament($tournament_id,$filter,$from,$to);
    //Get Round details
    $round = $viewer->getRoundOfTournament($tournament_id,$round_id);

    use Fr3ddy\Laratoor\ViewerApi;

    $viewer = new ViewerApi();

    //By Stage
    $tournament = $viewer->getTournament($tournament_id);
    $stage = $tournament->getStage($stage_id);
    //Get all Brackets of this stage with filter
    $brackets = $stage->getAllBrackets($filter);
    //Get Brackets of this stage with filter and pagination
    $brackets = $stage->getAllBrackets($filter,$from,$to);
    
    //By Tournament and Stage id
    //Get all Brackets of this stage with filter
    $brackets = $viewer->getAllBracketsOfStageInTournament($tournament_id,$stage_id,$filter);
    //Get Brackets of this stage with filter and pagination
    $brackets = $viewer->getBracketsOfStageInTournament($tournament_id,$stage_id,$filter,$from,$to);

    use Fr3ddy\Laratoor\ViewerApi;

    $viewer = new ViewerApi();

    //By Stage
    $tournament = $viewer->getTournament($tournament_id);
    $stage = $tournament->getStage($stage_id);
    //Get all Brackets of this stage with filter
    $rankings = $stage->getAllRankings($filter);
    //Get Brackets of this stage with filter and pagination
    $rankings = $stage->getRankings($filter,$from,$to);
    
    //By Tournament and Stage id
    //Get all Brackets of this stage with filter
    $rankings = $viewer->getAllRankingsOfStageInTournament($tournament_id,$stage_id,$filter);
    //Get Brackets of this stage with filter and pagination
    $rankings = $viewer->getRankingsOfStageInTournament($tournament_id,$stage_id,$filter,$from,$to);

    use Fr3ddy\Laratoor\ViewerApi;

    $viewer = new ViewerApi();

    //By Tournament
    $tournament = $viewer->getTournament($tournament_id);
    //All Matches with filter
    $matches = $tournament->getAllMatches($filter);
    //Matches with filter and pagination
    $matches = $tournament->getMatches($filter,$from,$to);
    //Match Details for one match of this tournament
    $match = $tournament->getMatch($match_id);

    //By Tournament ID
    //All Matches with filter
    $matches = $viewer->getAllMatchesOfTournament($tournament_id,$filter);
    //Matches with filter and pagination
    $matches = $viewer->getMatchesOfTournament($tournament_id,$filter,$from,$to);
    //Match Details for one match of this tournament
    $match = $viewer->getMatchOfTournament($tournament_id,$match_id);

    use Fr3ddy\Laratoor\ViewerApi;

    $viewer = new ViewerApi();

    //By Tournament
    $tournament = $viewer->getTournament($tournament_id);
    $match = $tournament->getMatch($match_id);
    //Get all games
    $games = $match->getGames();
    //Get game number 1
    $game = $match->getGame(1);

    use Fr3ddy\Laratoor\ViewerApi;

    $viewer = new ViewerApi();
    $match = $viewer->getMatchOfTournament($tournament_id,$match_id);
    $tournament = $match->getTournament();

    use Fr3ddy\Laratoor\ViewerApi;

    $viewer = new ViewerApi();

    //By IDs
    //Get all Streams of the tournament with filter
    $streams = $viewer->getAllStreamsOfTournament($tournament_id,$filter);
    //Get Streams with filter and pagination
    $streams = $viewer->getStreamsOfTournament($tournament_id,$filter,$from,$to);
    //Get all Videos of a tournament with filter
    $videos = $viewer->getAllVideosOfTournament($tournament_id,$filter);
    //Get Videos of tournament with filter and pagination
    $videos = $viewer->getVideosOfTournament($tournament_id,$filter,$from,$to);
    //Get all Videos of a match in the tournament with filter
    $videos = $viewer->getAllVideosOfMatchInTournament($tournament_id,$match_id,$filter);

    //By element
    $tournament = $viewer->getTournament($tournament_id);
    $match = $tournament->getMatch($match_id);
    //Get all Streams of the tournament with filter
    $streams = $tournament->getAllStreams($filter);
    //Get Streams with filter and pagination
    $streams = $tournament->getStreams($filter,$from,$to);
    //Get all Videos of a tournament with filter
    $videos = $tournament->getAllVideos($filter);
    //Get Videos of tournament with filter and pagination
    $videos = $tournament->getVideos($filter,$from,$to);
    //Get all Videos of a match in the tournament with filter
    $videos = $match->getAllVideos($filter);

    use Fr3ddy\Laratoor\AccountApi;

    Route::get('/', function () {
        $accountApi = new AccountApi();
        echo '<a href="'.$accountApi->getAuthUrl(url('/authorized')).'">Click me</a>';
    });

    Route::get('/authorized',function(){
        $accountApi = new AccountApi();
        $user = $accountApi->getUser();
        echo 'Hello '.$user->name.' from '.$user->country.'.';
    });