2018-01-09 06:22:26 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Repositories;
|
|
|
|
|
2019-07-16 03:44:31 +08:00
|
|
|
use App\Contracts\Repository;
|
2018-01-09 06:22:26 +08:00
|
|
|
use App\Models\News;
|
|
|
|
use Prettus\Repository\Contracts\CacheableInterface;
|
2018-02-21 12:33:09 +08:00
|
|
|
use Prettus\Repository\Traits\CacheableRepository;
|
2018-01-09 06:22:26 +08:00
|
|
|
|
2018-03-20 09:50:40 +08:00
|
|
|
/**
|
|
|
|
* Class NewsRepository
|
|
|
|
*/
|
|
|
|
class NewsRepository extends Repository implements CacheableInterface
|
2018-01-09 06:22:26 +08:00
|
|
|
{
|
|
|
|
use CacheableRepository;
|
|
|
|
|
|
|
|
public function model()
|
|
|
|
{
|
|
|
|
return News::class;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Latest news items
|
2018-08-27 00:40:04 +08:00
|
|
|
*
|
2018-01-09 06:22:26 +08:00
|
|
|
* @param int $count
|
2018-08-27 00:40:04 +08:00
|
|
|
*
|
2018-01-09 06:22:26 +08:00
|
|
|
* @return mixed
|
|
|
|
*/
|
2018-03-20 09:50:40 +08:00
|
|
|
public function getLatest($count = 5)
|
2018-01-09 06:22:26 +08:00
|
|
|
{
|
|
|
|
return $this->orderBy('created_at', 'desc')
|
2018-03-20 09:50:40 +08:00
|
|
|
->with(['user'])
|
|
|
|
->paginate($count);
|
2018-01-09 06:22:26 +08:00
|
|
|
}
|
|
|
|
}
|