我们是否可以在具有相同控制器和相同视图的laravel中对经过身份验证和未经过身份验证的用户使用相同的路由?

// route which should be used by authenticated and unauthenticated user 
Route::get('user/send-parcel', 'User\SenderController@sendParcerl');

I have tried to add this route in web (outside this auth middleware). It works fine but in my controller i have to add user id if the user is logged in if the user is not logged in the user_id field should contain the value of NULL.

$user = Auth::user();
$parcel->user_id = isset($user) ? $user->id : NULL;

The main problem is if i put the route outside of Auth middleware than it will not get the Auth in my controller. so the code works fine with unauthenticated user but for authenticated user it also put NULL in user_id field

The simple response is Yes, you can.

How it work, if you take a look at this page: https://laravel.com/docs/5.8/authentication#authentication-quickstart

You will see a section explaining how to check if the user is log in.

Determining If The Current User Is Authenticated

To determine if the user is already logged into your application, you may use the check method on the Auth facade, which will return true if the user is authenticated:

    use Illuminate\Support\Facades\Auth;

    if (Auth::check()) {
        // The user is logged in...
    }

So, in your controller, after adding the Auth facade, you can do this:

if (Auth::check()) {
    // do something with an authenticated user
} else {
   // do something with a non-authenticated user
}
// shared code between all kind of users

As mentioned into the documentation of Laravel, most of the time it's recommended to use a middleware and redirect to different controller.