-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented Layers for Infrastrucure, Domain and Application
- Loading branch information
0 parents
commit 624aed1
Showing
99 changed files
with
9,537 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/node_modules | ||
/public/hot | ||
/public/storage | ||
/storage/*.key | ||
/vendor | ||
.env | ||
.env.backup | ||
.phpunit.result.cache | ||
Homestead.json | ||
Homestead.yaml | ||
npm-debug.log | ||
yarn-error.log |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<p align="center"><img src="https://res.cloudinary.com/dtfbvvkyp/image/upload/v1566331377/laravel-logolockup-cmyk-red.svg" width="400"></p> | ||
|
||
<p align="center"> | ||
<a href="https://travis-ci.org/laravel/framework"><img src="https://travis-ci.org/laravel/framework.svg" alt="Build Status"></a> | ||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://poser.pugx.org/laravel/framework/d/total.svg" alt="Total Downloads"></a> | ||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://poser.pugx.org/laravel/framework/v/stable.svg" alt="Latest Stable Version"></a> | ||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://poser.pugx.org/laravel/framework/license.svg" alt="License"></a> | ||
</p> | ||
|
||
## About Laravel | ||
|
||
Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as: | ||
|
||
- [Simple, fast routing engine](https://laravel.com/docs/routing). | ||
- [Powerful dependency injection container](https://laravel.com/docs/container). | ||
- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage. | ||
- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent). | ||
- Database agnostic [schema migrations](https://laravel.com/docs/migrations). | ||
- [Robust background job processing](https://laravel.com/docs/queues). | ||
- [Real-time event broadcasting](https://laravel.com/docs/broadcasting). | ||
|
||
Laravel is accessible, powerful, and provides tools required for large, robust applications. | ||
|
||
## Learning Laravel | ||
|
||
Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework. | ||
|
||
If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains over 1500 video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library. | ||
|
||
## Laravel Sponsors | ||
|
||
We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the Laravel [Patreon page](https://patreon.com/taylorotwell). | ||
|
||
- **[Vehikl](https://vehikl.com/)** | ||
- **[Tighten Co.](https://tighten.co)** | ||
- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)** | ||
- **[64 Robots](https://64robots.com)** | ||
- **[Cubet Techno Labs](https://cubettech.com)** | ||
- **[Cyber-Duck](https://cyber-duck.co.uk)** | ||
- **[Many](https://www.many.co.uk)** | ||
- **[Webdock, Fast VPS Hosting](https://www.webdock.io/en)** | ||
- **[DevSquad](https://devsquad.com)** | ||
- [UserInsights](https://userinsights.com) | ||
- [Fragrantica](https://www.fragrantica.com) | ||
- [SOFTonSOFA](https://softonsofa.com/) | ||
- [User10](https://user10.com) | ||
- [Soumettre.fr](https://soumettre.fr/) | ||
- [CodeBrisk](https://codebrisk.com) | ||
- [1Forge](https://1forge.com) | ||
- [TECPRESSO](https://tecpresso.co.jp/) | ||
- [Runtime Converter](http://runtimeconverter.com/) | ||
- [WebL'Agence](https://weblagence.com/) | ||
- [Invoice Ninja](https://www.invoiceninja.com) | ||
- [iMi digital](https://www.imi-digital.de/) | ||
- [Earthlink](https://www.earthlink.ro/) | ||
- [Steadfast Collective](https://steadfastcollective.com/) | ||
- [We Are The Robots Inc.](https://watr.mx/) | ||
- [Understand.io](https://www.understand.io/) | ||
- [Abdel Elrafa](https://abdelelrafa.com) | ||
- [Hyper Host](https://hyper.host) | ||
- [Appoly](https://www.appoly.co.uk) | ||
- [OP.GG](https://op.gg) | ||
- [云软科技](http://www.yunruan.ltd/) | ||
|
||
## Contributing | ||
|
||
Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions). | ||
|
||
## Code of Conduct | ||
|
||
In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct). | ||
|
||
## Security Vulnerabilities | ||
|
||
If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [[email protected]](mailto:[email protected]). All security vulnerabilities will be promptly addressed. | ||
|
||
## License | ||
|
||
The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT). |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
namespace App\Application\CreateEbook; | ||
|
||
|
||
final class CreateEbook | ||
{ | ||
private $name; | ||
private $price; | ||
public function __construct(string $name, int $price) | ||
{ | ||
$this->name = $name; | ||
$this->price = $price; | ||
} | ||
|
||
public function name(): string | ||
{ | ||
return $this->name; | ||
} | ||
public function price(): int | ||
{ | ||
return $this->price; | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
namespace App\Application\CreateEbook; | ||
|
||
use App\Domain\Ebook\Ebook; | ||
use App\Domain\Ebook\EbookId; | ||
use App\Domain\Ebook\EbookRepository; | ||
|
||
final class CreateEbookService | ||
{ | ||
private $ebookRepository; | ||
public function __construct(EbookRepository $ebookRepository) | ||
{ | ||
$this->ebookRepository = $ebookRepository; | ||
} | ||
public function addEbookAction(CreateEbook $createEbook): EbookId | ||
{ | ||
$ebookId = $this->ebookRepository->identity(); | ||
$ebook = new Ebook( | ||
$ebookId, | ||
$createEbook->name(), | ||
$createEbook->price() | ||
); | ||
$this->ebookRepository->save($ebook); | ||
return $ebookId; | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
namespace App\Application\CreateOrder; | ||
|
||
|
||
final class CreateOrder | ||
{ | ||
private $ebookId; | ||
private $orderQuantity; | ||
private $emailAddress; | ||
public function __construct(string $ebookId, int $quantity, string $email_address) | ||
{ | ||
$this->ebookId = $ebookId; | ||
$this->orderQuantity = $quantity; | ||
$this->emailAddress = $email_address; | ||
} | ||
public function ebookId(): string | ||
{ | ||
return $this->ebookId; | ||
} | ||
public function orderQuantity(): int | ||
{ | ||
return $this->orderQuantity; | ||
} | ||
public function emailAddress(): string | ||
{ | ||
return $this->emailAddress; | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
namespace App\Application\CreateOrder; | ||
|
||
use App\Domain\Ebook\EbookId; | ||
use App\Domain\Ebook\EbookRepository; | ||
use App\Domain\Order\Order; | ||
use App\Domain\Order\OrderId; | ||
use App\Domain\Order\OrderRepository; | ||
|
||
final class CreateOrderService | ||
{ | ||
private $orderRepository; | ||
private $ebookRepository; | ||
|
||
public function __construct(OrderRepository $orderRepository, EbookRepository $ebookRepository) | ||
{ | ||
$this->orderRepository = $orderRepository; | ||
$this->ebookRepository = $ebookRepository; | ||
} | ||
|
||
public function create(CreateOrder $createOrder): OrderId | ||
{ | ||
$ebook = $this->ebookRepository->getById(EbookId::fromString($createOrder->ebookId())); | ||
$orderAmount = (int) $createOrder->orderQuantity() * (int) $ebook->price(); | ||
$orderId = $this->orderRepository->identity(); | ||
$order = new Order( | ||
$orderId, | ||
$createOrder->emailAddress(), | ||
$createOrder->orderQuantity(), | ||
$orderAmount | ||
); | ||
$this->orderRepository->save($order); | ||
return $orderId; | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace App\Application\ListAvailableEbooks; | ||
|
||
use App\Domain\Ebook\EbookId; | ||
|
||
final class Ebook | ||
{ | ||
private $id; | ||
private $name; | ||
private $price; | ||
public function __construct(EbookId $id, string $name, int $price) | ||
{ | ||
$this->name = $name; | ||
$this->price = $price; | ||
$this->id = $id; | ||
} | ||
public function ebookId(): string | ||
{ | ||
return $this->id->asString(); | ||
} | ||
public function title(): string | ||
{ | ||
return $this->name; | ||
} | ||
public function price(): string | ||
{ | ||
return Price::fromInt($this->price)->asFormattedAmount(); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
app/Application/ListAvailableEbooks/ListEBooksRepository.php
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
namespace App\Application\ListAvailableEbooks; | ||
|
||
|
||
interface ListEBooksRepository | ||
{ | ||
/** | ||
* @return array<Ebook> | ||
*/ | ||
public function listAvailableEbooks(): array; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
namespace App\Application\ListAvailableEbooks; | ||
|
||
final class Price | ||
{ | ||
private $priceInCents; | ||
private function __construct(int $priceInCents) | ||
{ | ||
$this->priceInCents = $priceInCents; | ||
} | ||
public static function fromInt(int $priceInCents): self | ||
{ | ||
return new self($priceInCents); | ||
} | ||
public function asInt(): int | ||
{ | ||
return $this->priceInCents; | ||
} | ||
|
||
public function asFormattedAmount(): string | ||
{ | ||
return strval($this->priceInCents); | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
namespace App\Application\ShowSingleEbook; | ||
|
||
use App\Application\ListAvailableEbooks\Ebook; | ||
use App\Domain\Ebook\EbookId; | ||
|
||
interface GetEbookRepository | ||
{ | ||
public function getEbook(EbookId $ebookId): Ebook; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
namespace App\Console; | ||
|
||
use Illuminate\Console\Scheduling\Schedule; | ||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel; | ||
|
||
class Kernel extends ConsoleKernel | ||
{ | ||
/** | ||
* The Artisan commands provided by your application. | ||
* | ||
* @var array | ||
*/ | ||
protected $commands = [ | ||
// | ||
]; | ||
|
||
/** | ||
* Define the application's command schedule. | ||
* | ||
* @param \Illuminate\Console\Scheduling\Schedule $schedule | ||
* @return void | ||
*/ | ||
protected function schedule(Schedule $schedule) | ||
{ | ||
// $schedule->command('inspire')->hourly(); | ||
} | ||
|
||
/** | ||
* Register the commands for the application. | ||
* | ||
* @return void | ||
*/ | ||
protected function commands() | ||
{ | ||
$this->load(__DIR__.'/Commands'); | ||
|
||
require base_path('routes/console.php'); | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
namespace App\Domain\Ebook; | ||
|
||
use Assert\Assertion; | ||
|
||
final class Ebook | ||
{ | ||
private $id; | ||
private $name; | ||
private $discount; | ||
private $price; | ||
public function __construct(EbookId $id, string $name, int $price) | ||
{ | ||
Assertion::greaterThan($price, 0); | ||
$this->name = $name; | ||
$this->price = $price; | ||
$this->id = $id; | ||
$this->discount = 0; | ||
} | ||
|
||
public function mappedData() | ||
{ | ||
return [ | ||
'uuid' => $this->id->asString(), | ||
'name' => $this->name, | ||
'price' => $this->price, | ||
'discount' => $this->discount, | ||
]; | ||
} | ||
|
||
public function addDiscount(int $discount) | ||
{ | ||
$this->discount = $discount; | ||
} | ||
} |
Oops, something went wrong.