Normally laravel will detect the base url automatically. However, this is not possible when the function is called by command line in console. Therefore, under path_to_laravel_folder/public/config/app.php, there is a variable named url, which according to the official comment, should be the base url when laravel is called in command line.
Currently I have a daily task to be run on laravel and therefore is called by command line. In the app.php, I have set the url variable to be:
'url' => 'http://localhost/laravel/public/',
However, when I check the output of my daily job, the base url is always
http://localhost/
Is this a bug or the sub-directory should be set else where?
P.S.
As suggested in the comment session, I am adding some details on what function I called for base url.
Actually, I am writing a daily job to send email to remind the user to do something on my site. It will first read from database on which user wants a reminder and sends a email if this user is found in our database. The function that need the base url is in the view file of the email, namely path_to_laravel/public/view/email/reminder.blade.php The code looks like this:
<!-- some other email content-->
... <a href="{{ url('/controllerName/method/'.$user_id) }}"> click here to go to the site </a> ....
<!-- some other email content -->
The $user_id is set in command file. The link will redirect to login page is user is not login yet.