Skip to content

Instantly share code, notes, and snippets.

@nahidulhasan
Last active May 23, 2018 04:33
Show Gist options
  • Save nahidulhasan/35f6b5d96697cb0f6648009f2a395a78 to your computer and use it in GitHub Desktop.
Save nahidulhasan/35f6b5d96697cb0f6648009f2a395a78 to your computer and use it in GitHub Desktop.
<?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