I have installed laravel 7 in my local server. When I run php artisan route:cache
command then laravel return error:
LogicException
Unable to prepare route [api/user] for serialization. Uses Closure.
How I can solve this problem?
I tried by running artisan commands:
php artisan config:cache
php artisan config:clear
php artisan cache:clear
composer dumpautoload
Here is content routes/api.php
:
<?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();
});