Hello,
I try to php artisan optimize, but I got this error message :
vagrant@homestead:~/code/crm$ php artisan optimize
Configuration cache cleared!
Configuration cached successfully!
Route cache cleared!
LogicException : Unable to prepare route [api/user] for serialization. Uses Closure.
at /home/vagrant/code/crm/vendor/laravel/framework/src/Illuminate/Routing/Route.php:917
913| */
914| public function prepareForSerialization()
915| {
916| if ($this->action['uses'] instanceof Closure) {
> 917| throw new LogicException("Unable to prepare route [{$this->uri}] for serialization. Uses Closure.");
918| }
919|
920| $this->compileRoute();
921|
Exception trace:
1 Illuminate\Routing\Route::prepareForSerialization()
/home/vagrant/code/crm/vendor/laravel/framework/src/Illuminate/Foundation/Console/RouteCacheCommand.php:62
2 Illuminate\Foundation\Console\RouteCacheCommand::handle()
/home/vagrant/code/crm/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:32
Please use the argument -v to see more details.
api.php
<?php
use Illuminate\Http\Request;
/*
|--------------------------------------------------------------------------
| 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!
|
*/
Auth::routes();
Route::middleware('auth:api')->get('/user', function (Request $request) {
return $request->user();
});
In web.php I use multiple routes starting by api/...
...
Route::group(['middleware' => ['auth'], 'as' => 'adminManagement'], function () {
Route::resource('api/permissions', 'PermissionController', [
'only' => ['index', 'show', 'store', 'update', 'destroy']
])->middleware('admin');
Route::resource('api/groups', 'GroupController', [
'only' => ['index', 'show', 'store', 'update', 'destroy']
])->middleware('admin');
Route::resource('api/members', 'UserController', [
'only' => ['index', 'show', 'store', 'update', 'destroy']
])->middleware('admin');
...