This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php namespace Repositories\Pokemon; | |
// model/Repositories/Pokemon/PokemonRepository.php | |
use Illuminate\Database\Eloquent\Model; | |
use \stdClass; | |
/** | |
* Our pokemon repository, containing commonly used queries | |
* 我們的 pokemon 資源庫,包含一些常用的查詢 | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php namespace Repositories\Pokemon; | |
// model\Repositories\Pokemon\PokemonRepositoryServiceProvider.php | |
use Entities\Pokemon; | |
use Repositories\Pokemon\PokemonRepository; | |
use Illuminate\Support\ServiceProvider; | |
/** | |
* Register our Repository with Laravel | |
* 註冊我們的資源庫到 Laravel |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php namespace Services\Pokemon; | |
// model/Services/Pokemon/PokemonServiceServiceProvider.php | |
use Illuminate\Support\ServiceProvider; | |
/** | |
* Register our pokemon service with Laravel | |
* 註冊我們的 pokemon 服務到 Laravel | |
*/ | |
class PokemonServiceServiceProvider extends ServiceProvider |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php namespace Services\Pokemon; | |
// model/Services/Pokemon/PokemonService.php | |
use Repositories\Pokemon\PokemonInterface; | |
/** | |
* Our PokemonService, containing all useful methods for business logic around Pokemon | |
* 我們的 PokemonService 服務,包含所有在 Pokemon 的商業邏輯中有用的方法 | |
*/ | |
class PokemonService |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php namespace Services\Pokemon; | |
// model/Services/Pokemon/PokemonFacade.php | |
use \Illuminate\Support\Facades\Facade; | |
/** | |
* Facade class to be called whenever the class PokemonService is called | |
* Facade 類別當 PokemonService 被呼叫時呼叫 | |
*/ | |
class PokemonFacade extends Facade { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"autoload": { | |
"classmap": [ | |
"app/models/entities", | |
"app/models/repositories", | |
"app/models/repositories/pokemon", | |
"app/models/services", | |
"app/models/services/pokemon", | |
] | |
}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// app/config/app.php | |
// .... | |
'providers' => array( | |
'Repositories\Pokemon\PokemonRepositoryServiceProvider', | |
'Services\Pokemon\PokemonServiceServiceProvider', | |
), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// app/config/app.php | |
// .... | |
'aliases' => array( | |
'Pokemon' => 'Services\Pokemon\PokemonFacade', | |
), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// app/database/migrations/2015_01_25_085024_create_pokemon_table.php | |
use Illuminate\Database\Schema\Blueprint; | |
use Illuminate\Database\Migrations\Migration; | |
class CreatePokemonTable extends Migration { | |
/** | |
* Run the migrations. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// A nice simple route to show a pokemons name if we can find it using our Service | |
Route::any('/pokemon/{pokemon}', function($pokemon) { | |
return Pokemon::getPokemon($pokemon); | |
}); |