en_btr_backend/routes/api.php

53 lines
1.8 KiB
PHP

<?php
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 within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/
Route::middleware('auth:api')->get('/user', function (Request $request) {
return $request->user();
});
Route::prefix('api/v1')->group(function () {
Route::post('contact/send', 'ContactController@send');
Route::get('commentary/{book}/chapter/{chapter}', 'CommentaryController@chapter');
Route::get('commentary/articles/{article}', 'CommentaryController@article');
});
JsonApi::register('default')->routes(function ($api) {
$api->resource('books')->readOnly()->relationships(function ($relations) {
$relations->hasMany('chapters')->readOnly();
});
$api->resource('chapters')->readOnly()->relationships(function ($relations) {
$relations->hasMany('verses')->readOnly();
});
$api->resource('verses')->readOnly()->relationships(function ($relations) {
$relations->hasMany('words')->readOnly();
});
$api->resource('words')->readOnly()->relationships(function ($relations) {
$relations->hasOne('lexical-entry')->readOnly();
$relations->hasOne('morph-legend')->readOnly();
});
$api->resource('lexical-entries')->readOnly()->relationships(function ($relations) {
$relations->hasMany('words')->readOnly();
});
$api->resource('morph-legends')->readOnly()->relationships(function ($relations) {
$relations->hasMany('words')->readOnly();
});
});