en_btr_backend/routes/api.php

53 lines
1.8 KiB
PHP
Raw Permalink Normal View History

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
Route::prefix('api/v1')->group(function () {
Route::post('contact/send', 'ContactController@send');
2021-05-26 21:51:34 +00:00
Route::get('commentary/{book}/chapter/{chapter}', 'CommentaryController@chapter');
Route::get('commentary/articles/{article}', 'CommentaryController@article');
});
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();
$relations->hasOne('morph-legend')->readOnly();
2020-10-07 03:28:24 +00:00
});
$api->resource('lexical-entries')->readOnly()->relationships(function ($relations) {
$relations->hasMany('words')->readOnly();
});
$api->resource('morph-legends')->readOnly()->relationships(function ($relations) {
$relations->hasMany('words')->readOnly();
});
2020-10-02 23:33:57 +00:00
});