2020-10-02 15:58:41 +00:00
|
|
|
<?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();
|
|
|
|
});
|
2020-10-02 23:33:57 +00:00
|
|
|
|
|
|
|
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();
|
|
|
|
});
|
|
|
|
|
2020-10-07 03:28:24 +00:00
|
|
|
$api->resource('words')->readOnly()->relationships(function ($relations) {
|
|
|
|
$relations->hasOne('lexical-entry')->readOnly();
|
|
|
|
});
|
|
|
|
|
|
|
|
$api->resource('lexical-entries')->readOnly()->relationships(function ($relations) {
|
|
|
|
$relations->hasMany('words')->readOnly();
|
|
|
|
});
|
2020-10-02 23:33:57 +00:00
|
|
|
});
|