phpvms/app/Http/Controllers/Api/NewsController.php
Nabeel S 12848091a2
Laravel 9 Update (#1413)
Update to Laravel 9 and PHP 8+

Co-authored-by: B.Fatih KOZ <fatih.koz@gmail.com>
2022-03-14 11:45:18 -04:00

40 lines
808 B
PHP

<?php
namespace App\Http\Controllers\Api;
use App\Contracts\Controller;
use App\Http\Resources\News as NewsResource;
use App\Repositories\NewsRepository;
use Illuminate\Http\Request;
class NewsController extends Controller
{
private NewsRepository $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);
}
}