I'm writing my project on Laravel. When I optimize the project, I have a problem :
Unable to prepare route [api/user] for serialization. Uses Closure.
I looked for any closures in web.php, but I didn't find anything
<?php
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::get('/','ReviewsController@main')->name('main');
Route::post('/','MailController@verify')->name('verifyPost');
Route::get('/reviews', 'ReviewsController@index')->name('reviews');
Route::post('/reviews','ReviewsController@add')->name('addReview');
Auth::routes();
Route::group(['middleware' => 'admin','prefix' => 'admin'],function () {
Route::get('/', 'HomeController@index')->name('admin');
Route::get('/reviews', 'Admin\ReviewsController@get')->name('admin.reviews');
Route::get('/reviews/accepted/{id}','Admin\ReviewsController@accept')->where('id','\d+')->name('admin.accepted');
Route::delete('/reviews/delete','Admin\ReviewsController@delete')->name('reviews.delete');
});
in api.php
file search and comment this route you will not get error..
Route::middleware('auth:api')->get('/user', function (Request $request) {
return $request->user();
});
and also in web.php
file route::group
is also closure and also comment them for test
Route::group(['middleware' => 'admin','prefix' => 'admin'],function () {
Route::get('/', 'HomeController@index')->name('admin');
Route::get('/reviews', 'Admin\ReviewsController@get')->name('admin.reviews');
Route::get('/reviews/accepted/{id}','Admin\ReviewsController@accept')->where('id','\d+')->name('admin.accepted');
Route::delete('/reviews/delete','Admin\ReviewsController@delete')->name('reviews.delete');
});
see what is closure
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With