2018-01-09 06:22:26 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Repositories;
|
|
|
|
|
|
|
|
use App\Models\News;
|
2018-02-02 06:46:37 +08:00
|
|
|
use Prettus\Repository\Traits\CacheableRepository;
|
2018-01-09 06:22:26 +08:00
|
|
|
use Prettus\Repository\Contracts\CacheableInterface;
|
|
|
|
|
|
|
|
class NewsRepository extends BaseRepository implements CacheableInterface
|
|
|
|
{
|
|
|
|
use CacheableRepository;
|
|
|
|
|
|
|
|
public function model()
|
|
|
|
{
|
|
|
|
return News::class;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Latest news items
|
|
|
|
* @param int $count
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public function getLatest($count=5)
|
|
|
|
{
|
|
|
|
return $this->orderBy('created_at', 'desc')
|
|
|
|
->with(['user'])
|
|
|
|
->paginate($count);
|
|
|
|
}
|
|
|
|
}
|