forked from Jexactyl/Jexactyl
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding the ability to display announcements
- Loading branch information
1 parent
ca5403a
commit 30203be
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
app/Http/Controllers/Api/Application/Utilites/AnnouncementController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
|
||
} |