]> BookStack Code Mirror - bookstack/blob - app/Http/Request.php
687bae9a6cb196e221d9c84ca33f3159da01f2ab
[bookstack] / app / Http / Request.php
1 <?php
2
3 namespace BookStack\Http;
4
5 use Illuminate\Http\Request as LaravelRequest;
6
7 class Request extends LaravelRequest
8 {
9     /**
10      * Override the default request methods to get the scheme and host
11      * to directly use the custom APP_URL, if set.
12      *
13      * @return string
14      */
15     public function getSchemeAndHttpHost()
16     {
17         $appUrl = config('app.url', null);
18
19         if ($appUrl) {
20             return implode('/', array_slice(explode('/', $appUrl), 0, 3));
21         }
22
23         return parent::getSchemeAndHttpHost();
24     }
25
26     /**
27      * Override the default request methods to get the base URL
28      * to directly use the custom APP_URL, if set.
29      *
30      * @return string
31      */
32     public function getBaseUrl()
33     {
34         $appUrl = config('app.url', null);
35
36         if ($appUrl) {
37             return rtrim(implode('/', array_slice(explode('/', $appUrl), 3)), '/');
38         }
39
40         return parent::getBaseUrl();
41     }
42 }