%PDF- %PDF-
Direktori : /var/www/html/news/app/Http/Controllers/Api/ |
Current File : /var/www/html/news/app/Http/Controllers/Api/NotificationsController.php |
<?php namespace App\Http\Controllers\Api; use App\Http\Controllers\ApiController; use App\Http\Requests\Media\NotificationUpdateRequest; use App\Repositories\Notification\NotificationRepository; use App\Transformers\NotificationTransformer; use EllipseSynergie\ApiResponse\Contracts\Response; class NotificationsController extends ApiController { /** * @var NotificationRepository */ private $notificationRepository; /** * NotificationsController constructor. * @param Response $response * @param NotificationRepository $notificationRepository */ public function __construct(Response $response, NotificationRepository $notificationRepository) { parent::__construct($response); $this->transformer = new NotificationTransformer; $this->notificationRepository = $notificationRepository; } /** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { return $this->response->withPaginator($this->notificationRepository->paginate(), $this->transformer); } /** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { return $this->response->withItem($this->notificationRepository->findOrFail($id), $this->transformer); } /** * Update the specified resource in storage. * * @param NotificationUpdateRequest $request * @param int $id * @return \Illuminate\Http\Response */ public function update(NotificationUpdateRequest $request, $id) { $category = $this->notificationRepository->findOrFail($id); $category->update($request->only([ 'send_notification_flag', 'subject', 'greeting', 'body', 'thank_you' ])); return $this->response->withItem($category, $this->transformer); } }