Laravel - Responses - Eloquent Models And Collections

You may also return Eloquent ORM models and collections directly from your routes and controllers. When you do, Laravel will automatically convert the models and collections to JSON responses while respecting the model's hidden attributes:

    
    use App\Models\User;
    
    Route::get('/user/{user}', function (User $user) {
        return $user;
    });