Last active
May 23, 2018 04:33
-
-
Save nahidulhasan/35f6b5d96697cb0f6648009f2a395a78 to your computer and use it in GitHub Desktop.
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
<?php | |
namespace Demo; | |
use DB; | |
class OrdersReport | |
{ | |
public function getOrdersInfo($startDate, $endDate) | |
{ | |
$orders = $this->queryDBForOrders($startDate, $endDate); | |
return $this->format($orders); | |
} | |
protected function queryDBForOrders($startDate, $endDate) | |
{ // If we would update our persistence layer in the future, | |
// we would have to do changes here too. <=> reason to change! | |
return DB::table('orders')->whereBetween('created_at', [$startDate, $endDate])->get(); | |
} | |
protected function format($orders) | |
{ // If we changed the way we want to format the output, | |
// we would have to make changes here. <=> reason to change! | |
return '<h1>Orders: ' . $orders . '</h1>'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment