Skip to content

Commit

Permalink
Add middleware to api routes
Browse files Browse the repository at this point in the history
  • Loading branch information
andrerei committed Aug 28, 2021
1 parent c77ebab commit a554f9c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 8 deletions.
8 changes: 8 additions & 0 deletions routes/api.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

use Illuminate\Support\Facades\Route;
use Manogi\Tiptap\Controllers\FilesController;
use Manogi\Tiptap\Controllers\ImagesController;

Route::post('file', FilesController::class.'@store');
Route::post('image', ImagesController::class.'@store');
6 changes: 0 additions & 6 deletions routes/web.php

This file was deleted.

23 changes: 21 additions & 2 deletions src/FieldServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Manogi\Tiptap;

use Illuminate\Support\Facades\Route;
use Laravel\Nova\Nova;
use Laravel\Nova\Events\ServingNova;
use Illuminate\Support\ServiceProvider;
Expand All @@ -15,20 +16,38 @@ class FieldServiceProvider extends ServiceProvider
*/
public function boot()
{
$this->loadRoutesFrom(__DIR__.'/../routes/web.php');
$this->app->booted(function () {
$this->routes();
});

Nova::provideToScript([
'novaTiptap' => [
'translations' => $this->translations()
]
]);

Nova::serving(function (ServingNova $event) {
Nova::script('tiptap', __DIR__.'/../dist/js/field.js');
Nova::style('tiptap', __DIR__.'/../dist/css/field.css');
});
}

/**
* Register routes.
*
* @return void
*/
protected function routes()
{
if ($this->app->routesAreCached()) {
return;
}

Route::middleware(['nova'])
->prefix('nova-tiptap/api')
->group(__DIR__.'/../routes/api.php');
}

/**
* Register any application services.
*
Expand Down

0 comments on commit a554f9c

Please sign in to comment.