Skip to content

Commit

Permalink
HeaderImages REST API Endpoint added
Browse files Browse the repository at this point in the history
  • Loading branch information
ttimot24 committed Aug 26, 2024
1 parent 3e283e4 commit c3c398e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 7 additions & 2 deletions app/Controllers/HeaderImageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,17 @@ public function before()
*
* @return \Illuminate\Http\Response
*/
public function index()
public function index(Request $request)
{
$activeImages = HeaderImage::active()->orderBy('order', 'ASC')->get();

if($request->wantsJson()){
return response()->json($activeImages);
}

$this->view->title(trans('Header Images'));
return $this->view->render('media/header_images', [
'slider_images' => HeaderImage::active()->orderBy('order', 'ASC')->get(),
'slider_images' => $activeImages,
'slider_disabled' => HeaderImage::inactive()->orderBy('order','ASC')->get(),
]);
}
Expand Down
2 changes: 2 additions & 0 deletions routes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
Route::apiResource('pages', \App\Controllers\PageController::class)
->only(['index', 'show']);

Route::apiResource('header-images', \App\Controllers\HeaderImageController::class)
->only(['index', 'show']);

Route::get('/users',function(Request $request){

Expand Down

0 comments on commit c3c398e

Please sign in to comment.