diff --git a/src/Http/Routes/Admin/ApiRoutes.php b/src/Http/Routes/Admin/ApiRoutes.php index cd79b62..4e1a13f 100644 --- a/src/Http/Routes/Admin/ApiRoutes.php +++ b/src/Http/Routes/Admin/ApiRoutes.php @@ -19,7 +19,7 @@ class ApiRoutes extends RouteRegistrar */ public function map() { - $this->prefix('api')->name('api.')->group(function () { + $this->name('api.')->group(function () { $this->get('all', 'MediasController@getAll') ->name('get'); // admin::media.api.get diff --git a/src/Providers/PackagesServiceProvider.php b/src/Providers/PackagesServiceProvider.php index 137f3ba..76e375d 100644 --- a/src/Providers/PackagesServiceProvider.php +++ b/src/Providers/PackagesServiceProvider.php @@ -10,5 +10,17 @@ */ class PackagesServiceProvider extends ServiceProvider { - // + /* ----------------------------------------------------------------- + | Main Methods + | ----------------------------------------------------------------- + */ + /** + * Register the service provider. + */ + public function register() + { + parent::register(); + + $this->registerProvider(\Arcanedev\LaravelApiHelper\ApiHelperServiceProvider::class); + } } diff --git a/src/Providers/RouteServiceProvider.php b/src/Providers/RouteServiceProvider.php index ef8917d..03fddcd 100644 --- a/src/Providers/RouteServiceProvider.php +++ b/src/Providers/RouteServiceProvider.php @@ -32,7 +32,9 @@ class RouteServiceProvider extends ServiceProvider public function map() { $this->adminGroup(function () { - $this->mapAdminRoutes(); + $this->name('media.')->group(function () { + $this->mapAdminRoutes(); + }); }); } @@ -41,11 +43,14 @@ public function map() */ protected function mapAdminRoutes() { - $this->name('media.') - ->prefix($this->config()->get('arcanesoft.media.route.prefix', 'media')) - ->group(function () { - Routes\Admin\MediaRoutes::register(); - Routes\Admin\ApiRoutes::register(); // TODO: Adding `api` or `ajax` middleware ? - }); + $prefix = $this->config()->get('arcanesoft.media.route.prefix', 'media'); + + $this->prefix($prefix)->group(function () { + Routes\Admin\MediaRoutes::register(); + }); + + $this->prefix("api/{$prefix}")->middleware('ajax')->group(function () { + Routes\Admin\ApiRoutes::register(); + }); } }