File tree Expand file tree Collapse file tree 2 files changed +34
-7
lines changed
Expand file tree Collapse file tree 2 files changed +34
-7
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace App \Http \Traits ;
4+
5+ use Illuminate \Support \Facades \App ;
6+ use Illuminate \Support \Facades \URL ;
7+
8+ trait URLScheme {
9+
10+ /**
11+ * This function will check if the app is running on the
12+ * local environment or production environment
13+ *
14+ * @return bool
15+ */
16+ public function isSecureScheme (): bool
17+ {
18+ return App::environment ('local ' ) ? false : true ;
19+ }
20+
21+ /**
22+ * This function will set the URL scheme based on the environment.
23+ */
24+ public function checkURLScheme () {
25+ if (App::environment ('local ' )) {
26+ URL ::forceScheme ('http ' );
27+ } else {
28+ URL ::forceScheme ('https ' );
29+ }
30+ }
31+ }
Original file line number Diff line number Diff line change 22
33namespace App \Providers ;
44
5- use Illuminate \Support \Facades \App ;
6- use Illuminate \Support \Facades \URL ;
5+ use App \Http \Traits \URLScheme ;
76use Illuminate \Support \ServiceProvider ;
87
98class AppServiceProvider extends ServiceProvider
109{
10+ use URLScheme;
1111 /**
1212 * Register any application services.
1313 *
@@ -25,10 +25,6 @@ public function register()
2525 */
2626 public function boot ()
2727 {
28- if (App::Environment ('local ' )) {
29- URL ::forceScheme ('http ' );
30- } else {
31- URL ::forceScheme ('https ' );
32- }
28+ $ this ->checkURLScheme ();
3329 }
3430}
You can’t perform that action at this time.
0 commit comments