vitta minicurso laravel - hackathon league of legends
TRANSCRIPT
![Page 1: Vitta Minicurso Laravel - Hackathon League of Legends](https://reader036.vdocument.in/reader036/viewer/2022062523/58f316be1a28abab428b45ef/html5/thumbnails/1.jpg)
INTRODUÇÃO AOLARAVEL
![Page 2: Vitta Minicurso Laravel - Hackathon League of Legends](https://reader036.vdocument.in/reader036/viewer/2022062523/58f316be1a28abab428b45ef/html5/thumbnails/2.jpg)
DESENVOLVIMENTO EM TIME
CONVERSA DE GENTE GRANDE
![Page 3: Vitta Minicurso Laravel - Hackathon League of Legends](https://reader036.vdocument.in/reader036/viewer/2022062523/58f316be1a28abab428b45ef/html5/thumbnails/3.jpg)
MODEL
VIEWCONTROLER
![Page 4: Vitta Minicurso Laravel - Hackathon League of Legends](https://reader036.vdocument.in/reader036/viewer/2022062523/58f316be1a28abab428b45ef/html5/thumbnails/4.jpg)
![Page 5: Vitta Minicurso Laravel - Hackathon League of Legends](https://reader036.vdocument.in/reader036/viewer/2022062523/58f316be1a28abab428b45ef/html5/thumbnails/5.jpg)
LARAVELBRINGING PHP BACK =)
![Page 6: Vitta Minicurso Laravel - Hackathon League of Legends](https://reader036.vdocument.in/reader036/viewer/2022062523/58f316be1a28abab428b45ef/html5/thumbnails/6.jpg)
Taylor Otwellhttps://github.com/taylorotwellCR
IAD
OR
![Page 7: Vitta Minicurso Laravel - Hackathon League of Legends](https://reader036.vdocument.in/reader036/viewer/2022062523/58f316be1a28abab428b45ef/html5/thumbnails/7.jpg)
CON
TRIB
UID
ORE
SDayle Reeshttps://github.com/daylerees
![Page 8: Vitta Minicurso Laravel - Hackathon League of Legends](https://reader036.vdocument.in/reader036/viewer/2022062523/58f316be1a28abab428b45ef/html5/thumbnails/8.jpg)
DOCUMENTAÇÃO
ONLINE: http://laravel.com/docs/
GITHUB:https://github.com/laravel/laravel
![Page 9: Vitta Minicurso Laravel - Hackathon League of Legends](https://reader036.vdocument.in/reader036/viewer/2022062523/58f316be1a28abab428b45ef/html5/thumbnails/9.jpg)
AMBIENTEA PARTE… MENOS… DIVERTIDA
![Page 10: Vitta Minicurso Laravel - Hackathon League of Legends](https://reader036.vdocument.in/reader036/viewer/2022062523/58f316be1a28abab428b45ef/html5/thumbnails/10.jpg)
AMBIENTE WINDOWS
1. INSTALADOR WT-NMP
![Page 11: Vitta Minicurso Laravel - Hackathon League of Legends](https://reader036.vdocument.in/reader036/viewer/2022062523/58f316be1a28abab428b45ef/html5/thumbnails/11.jpg)
AMBIENTE WINDOWS
2. EDITE O ARQUIVO DE HOSTSC:\WINDOWS\SYSTEM32\DRIVERS\ETC\hosts
127.1.1.1 meuapp.dev
![Page 12: Vitta Minicurso Laravel - Hackathon League of Legends](https://reader036.vdocument.in/reader036/viewer/2022062523/58f316be1a28abab428b45ef/html5/thumbnails/12.jpg)
3. CONFIGURE O NGINXserver {
listen 127.1.1.1;server_name meuapp.dev;
root C:\WT-NMP\WWW\meuapp\public;index index.php;charset utf-8;
location / {try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {try_files $uri /index.php =404;fastcgi_split_path_info ^(.+\.php)(/.+)$;fastcgi_pass php_farm;fastcgi_param SCRIPT_FILENAME
$document_root$fastcgi_script_name;include nginx.fastcgi.conf;
}}
![Page 13: Vitta Minicurso Laravel - Hackathon League of Legends](https://reader036.vdocument.in/reader036/viewer/2022062523/58f316be1a28abab428b45ef/html5/thumbnails/13.jpg)
AMBIENTE LINUX
1. INSTALAR LEMP
![Page 14: Vitta Minicurso Laravel - Hackathon League of Legends](https://reader036.vdocument.in/reader036/viewer/2022062523/58f316be1a28abab428b45ef/html5/thumbnails/14.jpg)
AMBIENTE LINUX
2. EDITE O ARQUIVO DE HOSTS/ETC/HOSTS
127.1.1.1 meuapp.dev
![Page 15: Vitta Minicurso Laravel - Hackathon League of Legends](https://reader036.vdocument.in/reader036/viewer/2022062523/58f316be1a28abab428b45ef/html5/thumbnails/15.jpg)
3. CONFIGURE O NGINXserver {
listen 127.1.1.1;server_name meuapp.dev;
root /var/www/html/meuapp/public;index index.php;charset utf-8;
location / {try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {try_files $uri /index.php =404;fastcgi_split_path_info ^(.+\.php)(/.+)$;fastcgi_pass php_farm;fastcgi_param SCRIPT_FILENAME
$document_root$fastcgi_script_name;include nginx.fastcgi.conf;
}}
![Page 16: Vitta Minicurso Laravel - Hackathon League of Legends](https://reader036.vdocument.in/reader036/viewer/2022062523/58f316be1a28abab428b45ef/html5/thumbnails/16.jpg)
4. CONFIGURE BANCO DE DADOSCRIE UM DATABASE “MEU-APP-DEV”CHARSET: UTF-8 ( UTF8_UNICODE_CI )
5. INSTALE O COMPOSER
6. CRIE UM PROJETO LARAVEL
OU
>_ curl -sS https://getcomposer.org/installer | php
>_ composer create-project laravel/laravel meuapp --prefer-dist
>_ composer global require "laravel/installer=~1.1“>_ laravel new meuapp
![Page 17: Vitta Minicurso Laravel - Hackathon League of Legends](https://reader036.vdocument.in/reader036/viewer/2022062523/58f316be1a28abab428b45ef/html5/thumbnails/17.jpg)
7. CONFIGURE O LARAVELTENHA CERTEZA DE TER PERMISSÕES DE ESCRITA NOS DIRETÓRIOS
/MEUAPP/BOOSTRAP/MEUAPP/STORAGE
GERE UMA CHAVE PARA CRIPTOGRAFAR AS SENHAS
/MEUAPP/.ENV
>_ php artisan key:generate
APP_ENV=devAPP_DEBUG=true
DB_HOST=localhostDB_DATABASE=MEU-APP-DEVDB_USERNAME=rootDB_PASSWORD=
![Page 18: Vitta Minicurso Laravel - Hackathon League of Legends](https://reader036.vdocument.in/reader036/viewer/2022062523/58f316be1a28abab428b45ef/html5/thumbnails/18.jpg)
7. CONFIGURE O LARAVEL/MEUAPP/CONFIG/APP.PHP
/MEUAPP/CONFIG/DATABASE.PHP'debug' => env('APP_DEBUG', true),
'default' => ‘dev',
'connections' => [ ‘dev' => [ 'driver‘ => 'mysql', 'host‘ => env(‘DB_HOST'), 'database' => env(‘DB_DATABASE'), 'username' => env(‘DB_USERNAME'), 'password' => env(‘DB_PASSWORD'), 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', ], ],
![Page 19: Vitta Minicurso Laravel - Hackathon League of Legends](https://reader036.vdocument.in/reader036/viewer/2022062523/58f316be1a28abab428b45ef/html5/thumbnails/19.jpg)
7. CONFIGURE O LARAVELATUALIZE AS DEPENDENCIAS DO LARAVEL COM O COMPOSER (SE NECESSÁRIO)>_ composer install>_ composer update -o
![Page 20: Vitta Minicurso Laravel - Hackathon League of Legends](https://reader036.vdocument.in/reader036/viewer/2022062523/58f316be1a28abab428b45ef/html5/thumbnails/20.jpg)
MEU PRIMEIRO APPACESSE HTTP://MEUAPP.DEV/
![Page 21: Vitta Minicurso Laravel - Hackathon League of Legends](https://reader036.vdocument.in/reader036/viewer/2022062523/58f316be1a28abab428b45ef/html5/thumbnails/21.jpg)
![Page 22: Vitta Minicurso Laravel - Hackathon League of Legends](https://reader036.vdocument.in/reader036/viewer/2022062523/58f316be1a28abab428b45ef/html5/thumbnails/22.jpg)
/APP/TODO O CÓDIGO COM A LÓGICA DO BACK-END.
/CONFIG/TODAS AS CONFIGURAÇÕES DO SEU APP.
/DATABASE/SCRIPT CRIADORES DE TABELAS E SEEDERS.
/PUBLIC/ROOT DA ACESSADA PELO USUÁRIO, É AONDE FICAM OS ARQUIVOS PÚBLICOS DO SEU SITE COMO JAVASCRIPT E IMAGENS.
![Page 23: Vitta Minicurso Laravel - Hackathon League of Legends](https://reader036.vdocument.in/reader036/viewer/2022062523/58f316be1a28abab428b45ef/html5/thumbnails/23.jpg)
/RESOURCES/ARQUIVOS GERADORES DE ARQUIVOS PÚBLICOS E GERADORES DE RESPOSTAS HTML (VIEWS).
/STORAGE/GUARDA TODOS OS ARQUIVOS DE CONTROLE DO FRAMEWORK COMO SESSÕES E LOGS.
/TESTS/SALVA OS TESTES AUTOMATIZADOS
/VENDOR/PACOTES DE TERCEIROS
![Page 24: Vitta Minicurso Laravel - Hackathon League of Legends](https://reader036.vdocument.in/reader036/viewer/2022062523/58f316be1a28abab428b45ef/html5/thumbnails/24.jpg)
/.ENVSALVA SUAS CONFIGURAÇÕES DE AMBIENTE
/COMPOSER.JSONDEFINE AS DEPENDÊNCIAS DO SEU APP
/ARTISANDISPARADOR DE
![Page 25: Vitta Minicurso Laravel - Hackathon League of Legends](https://reader036.vdocument.in/reader036/viewer/2022062523/58f316be1a28abab428b45ef/html5/thumbnails/25.jpg)
![Page 26: Vitta Minicurso Laravel - Hackathon League of Legends](https://reader036.vdocument.in/reader036/viewer/2022062523/58f316be1a28abab428b45ef/html5/thumbnails/26.jpg)
![Page 27: Vitta Minicurso Laravel - Hackathon League of Legends](https://reader036.vdocument.in/reader036/viewer/2022062523/58f316be1a28abab428b45ef/html5/thumbnails/27.jpg)
![Page 28: Vitta Minicurso Laravel - Hackathon League of Legends](https://reader036.vdocument.in/reader036/viewer/2022062523/58f316be1a28abab428b45ef/html5/thumbnails/28.jpg)
HACKATHONVAMOS BOTAR A MÃO NA MASSA
![Page 29: Vitta Minicurso Laravel - Hackathon League of Legends](https://reader036.vdocument.in/reader036/viewer/2022062523/58f316be1a28abab428b45ef/html5/thumbnails/29.jpg)
![Page 30: Vitta Minicurso Laravel - Hackathon League of Legends](https://reader036.vdocument.in/reader036/viewer/2022062523/58f316be1a28abab428b45ef/html5/thumbnails/30.jpg)
FAÇA SEU CADASTRO NA API DA RIOT GAMES:https://developer.riotgames.com/
SALVE SUA API-KEY NO SEU /.ENV
VOCÊ PODE VERIFICAR TODOS OS ENDPOINTS DA API AQUI:
https://developer.riotgames.com/api/methods
RIOT_KEY=11111111-1111-1111-1111-111111111111
![Page 31: Vitta Minicurso Laravel - Hackathon League of Legends](https://reader036.vdocument.in/reader036/viewer/2022062523/58f316be1a28abab428b45ef/html5/thumbnails/31.jpg)
CRIE UMA MIGRAÇÃO PARA CRIAR A TABELA DE VERSÃO
ABRA O ARQUIVO GERADO AUTOMATICAMENTE/DATABASE/MIGRATIONS/XXXX_XX_XX_XXXXXX_CREATE_VERSIONS_TABLE.PHP
>_ php artisan make:migration create_versions_table
public function up() { Schema::create('versions', function (Blueprint $table) { $table->increments('id'); $table->string('release')->nullable(); $table->timestamps(); }); }
public function down() { Schema::drop('versions'); }
![Page 32: Vitta Minicurso Laravel - Hackathon League of Legends](https://reader036.vdocument.in/reader036/viewer/2022062523/58f316be1a28abab428b45ef/html5/thumbnails/32.jpg)
![Page 33: Vitta Minicurso Laravel - Hackathon League of Legends](https://reader036.vdocument.in/reader036/viewer/2022062523/58f316be1a28abab428b45ef/html5/thumbnails/33.jpg)
CRIE UM MODEL PARA ACESSAR O BANCO DE DADOS
ABRA O ARQUIVO GERADO AUTOMATICAMENTE/APP/VERSION.PHP
>_ php artisan make:model Version
![Page 34: Vitta Minicurso Laravel - Hackathon League of Legends](https://reader036.vdocument.in/reader036/viewer/2022062523/58f316be1a28abab428b45ef/html5/thumbnails/34.jpg)
![Page 35: Vitta Minicurso Laravel - Hackathon League of Legends](https://reader036.vdocument.in/reader036/viewer/2022062523/58f316be1a28abab428b45ef/html5/thumbnails/35.jpg)
CRIE SEEDERS PARA POPULAR AS TABELAS
ABRA O ARQUIVO GERADO AUTOMATICAMENTE/DATABASE/SEEDS/VERSIONSSEEDER.php
ADICIONE A SEGUINTE LINHA NO COMEÇO DO ARQUIVO
VAMOS CRIAR UMA FUNÇÃO QUE: FAÇA UMA PERGUNTA PARA A API E CAPITURE AS VERSÕES DO JOGO SALVE AS VERSÕES NO BANCO DE DADOS
>_ php artisan make:seed VersionsSeeder
use App\Version;
![Page 36: Vitta Minicurso Laravel - Hackathon League of Legends](https://reader036.vdocument.in/reader036/viewer/2022062523/58f316be1a28abab428b45ef/html5/thumbnails/36.jpg)
![Page 37: Vitta Minicurso Laravel - Hackathon League of Legends](https://reader036.vdocument.in/reader036/viewer/2022062523/58f316be1a28abab428b45ef/html5/thumbnails/37.jpg)
ABRA O ARQUIVO SEEDER/DATABASE/SEEDS/DATABASESEEDER.php
PARA TESTAR O SEEDER PODEMOS A QUALQUER MOMENTO RODAR:
UM ESPECÍFICO SEED:
$this->call(VersionsSeeder::class);
>_ php artisan db:seed
>_ php artisan db:seed --class=VersionsSeeder
![Page 38: Vitta Minicurso Laravel - Hackathon League of Legends](https://reader036.vdocument.in/reader036/viewer/2022062523/58f316be1a28abab428b45ef/html5/thumbnails/38.jpg)
CRIE MIGRAÇÕES PARA GERAR AS TABELAS
ABRA O ARQUIVO GERADO AUTOMATICAMENTE/DATABASE/MIGRATIONS/XXXX_XX_XX_XXXXXX_CREATE_CHAMPIONS_TABLE.PHP
>_ php artisan make:migration create_champions_table
Schema::create('champions', function (Blueprint $table) { $table->increments('id'); $table->integer('riot_id')->index(); $table->string('name'); $table->string('title'); $table->string('key'); $table->string('image')->nullable(); $table->string('tags')->nullable(); $table->string('stats')->nullable(); $table->text('enemytips')->nullable(); $table->text('lore')->nullable(); $table->timestamps(); });
![Page 39: Vitta Minicurso Laravel - Hackathon League of Legends](https://reader036.vdocument.in/reader036/viewer/2022062523/58f316be1a28abab428b45ef/html5/thumbnails/39.jpg)
CRIE UM MODEL PARA ACESSAR O BANCO DE DADOS
VAMOS JÁ TAMBÉM CRIAR O SEEDER PARA OS CHAMPIONS
ABRA O ARQUIVO GERADO AUTOMATICAMENTE/DATABASE/SEEDS/VERSIONSSEEDER.php
E CRIAREMOS UMA FUNÇÃO QUE: CAPTURE OS CHAMPIONS SALVE OS CHAMPIONS COM INFORMAÇÕES ATUALIZADAS DA ÚLTIMA
VERSÃO
>_ php artisan make:model Champion
>_ php artisan make:seed ChampionsSeeder
![Page 40: Vitta Minicurso Laravel - Hackathon League of Legends](https://reader036.vdocument.in/reader036/viewer/2022062523/58f316be1a28abab428b45ef/html5/thumbnails/40.jpg)
DICAS PARA FAZER A FUNÇÃO:ENDPOINT:
PARA CONSEGUIR A FOTO DO PERSONAGEM USE:
“https://global.api.pvp.net/api/lol/static-data/br/v1.2/champion?champData=all&api_key=“.env(“RIOT_KEY)
http://ddragon.leagueoflegends.com/cdn/{VERSÃO}/img/champion/{NOME}.png
![Page 41: Vitta Minicurso Laravel - Hackathon League of Legends](https://reader036.vdocument.in/reader036/viewer/2022062523/58f316be1a28abab428b45ef/html5/thumbnails/41.jpg)
![Page 42: Vitta Minicurso Laravel - Hackathon League of Legends](https://reader036.vdocument.in/reader036/viewer/2022062523/58f316be1a28abab428b45ef/html5/thumbnails/42.jpg)
AGORA VAMOS VISUALIZAR AS INFORMAÇÕES QUE CONSEGUIMOS!
CRIE UM DIRETÓRIO:/RESOURCES/VIEWS/LAYOUTS/
CRIE UM ARQUIVO:PUBLIC.BLADE.PHP
![Page 43: Vitta Minicurso Laravel - Hackathon League of Legends](https://reader036.vdocument.in/reader036/viewer/2022062523/58f316be1a28abab428b45ef/html5/thumbnails/43.jpg)
![Page 44: Vitta Minicurso Laravel - Hackathon League of Legends](https://reader036.vdocument.in/reader036/viewer/2022062523/58f316be1a28abab428b45ef/html5/thumbnails/44.jpg)
CRIE UM DIRETÓRIO:/RESOURCES/VIEWS/CHAMPIONS/
CRIE OS ARQUIVOS:INDEX.BLADE.PHPSHOW.BLADE.PHP
![Page 45: Vitta Minicurso Laravel - Hackathon League of Legends](https://reader036.vdocument.in/reader036/viewer/2022062523/58f316be1a28abab428b45ef/html5/thumbnails/45.jpg)
![Page 46: Vitta Minicurso Laravel - Hackathon League of Legends](https://reader036.vdocument.in/reader036/viewer/2022062523/58f316be1a28abab428b45ef/html5/thumbnails/46.jpg)
![Page 47: Vitta Minicurso Laravel - Hackathon League of Legends](https://reader036.vdocument.in/reader036/viewer/2022062523/58f316be1a28abab428b45ef/html5/thumbnails/47.jpg)
AGORA TEMOS QUE CRIAR O CONTROLLER:
VÁ PARA O ARQUIVO GERADO AUTOMATICAMENTE:/APP/HTTP/CONTROLLERS/CHAMPIONSCONTROLLER.PHP
NO COMEÇO DO ARQUIVO CHAME:
>_ php artisan make:controller ChampionsController
use App\Champion;
![Page 48: Vitta Minicurso Laravel - Hackathon League of Legends](https://reader036.vdocument.in/reader036/viewer/2022062523/58f316be1a28abab428b45ef/html5/thumbnails/48.jpg)
NO MÉTODO INDEX:
NO MÉTODO SHOW:
public function index() { $champions = Champion::all(); return view(‘champions.index')->with('champions‘,$champions); }
public function show($id) { $champion = Champion::find($id) return view('champions.show')->with('champion',$champion); }
![Page 49: Vitta Minicurso Laravel - Hackathon League of Legends](https://reader036.vdocument.in/reader036/viewer/2022062523/58f316be1a28abab428b45ef/html5/thumbnails/49.jpg)
AGORA VAMOS CRIAR AS ROTAS:
VÁ PARA O ARQUIVO GERADO AUTOMATICAMENTE:/APP/HTTP/ROUTES.PHP
ADICIONE AS SEGUINTES LINHAS:Route::get('/','ChampionsController@index');Route::get('/champions/{id}','ChampionsController@show');
![Page 50: Vitta Minicurso Laravel - Hackathon League of Legends](https://reader036.vdocument.in/reader036/viewer/2022062523/58f316be1a28abab428b45ef/html5/thumbnails/50.jpg)
![Page 51: Vitta Minicurso Laravel - Hackathon League of Legends](https://reader036.vdocument.in/reader036/viewer/2022062523/58f316be1a28abab428b45ef/html5/thumbnails/51.jpg)
![Page 52: Vitta Minicurso Laravel - Hackathon League of Legends](https://reader036.vdocument.in/reader036/viewer/2022062523/58f316be1a28abab428b45ef/html5/thumbnails/52.jpg)
SUA VEZ!
DIVIDAM-SE EM DUPLAS E FAÇAM COMPLETEM OS DESAFIOS:
FAZER GRÁFICOS DOS ATRIBUTOS DOS CHAMPIONS
FAZER UM CRIADOR AUTOMÁTICO DE TIMES