phpvms/app/Repositories/NewsRepository.php

36 lines
665 B
PHP
Raw Normal View History

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