2018-04-12 09:01:41 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\Api;
|
|
|
|
|
2019-07-16 03:44:31 +08:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|