Skip to content

Commit

Permalink
Adding the ability to display announcements
Browse files Browse the repository at this point in the history
  • Loading branch information
kokofixcomputers authored Oct 13, 2024
1 parent ca5403a commit 30203be
Showing 1 changed file with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace App\Http\Controllers\Api;

use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Support\Collection;
use App\Http\Controllers\Controller;
use App\Models\Announcement;
use App\Transformers\AnnouncementTransformer;

class AnnouncementController extends ApplicationApiController
{
/**
* Display a listing of announcements.
*
* @return \Illuminate\Http\JsonResponse
*/
public function index()
{
$announcements = Announcement::all();
$data = $this->fractal
->createData($this->getTransformer(AnnouncementTransformer::class)->transformCollection($announcements))
->toArray();
return response()->json($data);
}

}

0 comments on commit 30203be

Please sign in to comment.