public function getRankingStockList($limit, $day_period = null)
{
$options = array($limit);
$where = '';
if (!empty($day_period)) {
$where = <<<__SQL__
where i.created_at > ?
__SQL__;
$period = Carbon::now()->subDays($day_period);
array_unshift($options, $period);
}
$query = <<<__SQL__
select
*
from
items as i
inner join (
select
s.item_id, count(*) as stock_count
from
stocks s
group by
s.item_id
) as sc on i.id = sc.item_id
{$where}
and i.published = 2
order by
sc.stock_count desc
limit ?
__SQL__;
return \DB::select($query, $options);
}