phpvms/app/Repositories/NewsRepository.php

30 lines
607 B
PHP
Raw Normal View History

<?php
namespace App\Repositories;
use App\Models\News;
use Prettus\Repository\Contracts\CacheableInterface;
2018-02-21 12:33:09 +08:00
use Prettus\Repository\Traits\CacheableRepository;
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);
}
}