54 lines
1.8 KiB
PHP
54 lines
1.8 KiB
PHP
<?php
|
|
|
|
use App\Http\Controllers\Api\ArticleController;
|
|
use App\Http\Controllers\Api\HomepageController;
|
|
use App\Http\Controllers\Api\PageController;
|
|
use App\Http\Controllers\Api\PublicDocumentController;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\Route;
|
|
|
|
/*
|
|
|--------------------------------------------------------------------------
|
|
| API Routes
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
| Here is where you can register API routes for your application. These
|
|
| routes are loaded by the RouteServiceProvider and all of them will
|
|
| be assigned to the "api" middleware group. Make something great!
|
|
|
|
|
*/
|
|
|
|
Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
|
|
return $request->user();
|
|
});
|
|
|
|
// Public API v1
|
|
Route::prefix('v1')->group(function () {
|
|
// Articles
|
|
Route::get('/articles', [ArticleController::class, 'index']);
|
|
Route::get('/articles/{slug}', [ArticleController::class, 'show']);
|
|
Route::get('/articles/{slug}/attachments/{id}/download', [ArticleController::class, 'downloadAttachment']);
|
|
|
|
// Categories
|
|
Route::get('/categories', function () {
|
|
$categories = \App\Models\ArticleCategory::withCount(['articles' => function ($q) {
|
|
$q->active()->forAccessLevel();
|
|
}])
|
|
->orderBy('sort_order')
|
|
->get();
|
|
|
|
return \App\Http\Resources\CategoryResource::collection($categories);
|
|
});
|
|
|
|
// Pages
|
|
Route::get('/pages/{slug}', [PageController::class, 'show']);
|
|
|
|
// Homepage
|
|
Route::get('/homepage', [HomepageController::class, 'index']);
|
|
|
|
// Public documents (from member document library)
|
|
Route::get('/public-documents', [PublicDocumentController::class, 'index']);
|
|
Route::get('/public-documents/{uuid}', [PublicDocumentController::class, 'show'])
|
|
->whereUuid('uuid');
|
|
});
|