phpvms/app/Http/Controllers/Api/NewsController.php

39 lines
814 B
PHP
Raw Normal View History

2018-04-12 09:01:41 +08:00
<?php
namespace App\Http\Controllers\Api;
use App\Http\Resources\News as NewsResource;
use App\Interfaces\Controller;
use App\Repositories\NewsRepository;
use Illuminate\Http\Request;
/**
* @package App\Http\Controllers\Api
*/
class NewsController extends Controller
{
private $newsRepo;
/**
* AirlineController constructor.
* @param NewsRepository $newsRepo
*/
public function __construct(NewsRepository $newsRepo) {
$this->newsRepo = $newsRepo;
}
/**
* Return all the airlines, paginated
* @param Request $request
* @return mixed
*/
public function index(Request $request)
{
$news = $this->newsRepo
->orderBy('created_at', 'desc')
->paginate();
return NewsResource::collection($news);
}
}