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

40 lines
793 B
PHP
Raw Normal View History

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