en_btr_backend/routes/api.php

42 lines
1.3 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();
});
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();
});
$api->resource('lexical-entries')->readOnly()->relationships(function ($relations) {
$relations->hasMany('words')->readOnly();
});
});