Skip to content

Commit 51a1f0c

Browse files
committed
Fix: Now you can use this project in subfolder of domain
1 parent 843f263 commit 51a1f0c

File tree

14 files changed

+41
-17
lines changed

14 files changed

+41
-17
lines changed

README.md

+13
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,19 @@ Then in file ".env" complete this database configuration:
141141
* DB_USERNAME=root
142142
* DB_PASSWORD=
143143

144+
### If your project is in subfolder
145+
146+
> If your project url looks like: example.com/sub-folder
147+
Then go to `my-project/.env`
148+
And modify this line:
149+
```php
150+
APP_URL = '';
151+
```
152+
To make it look like this:
153+
```php
154+
APP_URL = 'http://example.com/sub-folder';
155+
```
156+
144157
### Next step
145158

146159
``` bash

app/Http/Controllers/MenuElementController.php

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use App\Http\Menus\GetSidebarMenu;
99
use App\Models\Menulist;
1010
use App\Models\Menus;
11-
use App\Models\MenusLang;
1211
use Illuminate\Validation\Rule;
1312
use App\Services\RolesService;
1413

database/seeds/MenusTableSeeder.php

+12
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class MenusTableSeeder extends Seeder
1313
private $joinData = array();
1414
private $adminRole = null;
1515
private $userRole = null;
16+
private $subFolder = '';
1617

1718
public function join($roles, $menusId){
1819
$roles = explode(',', $roles);
@@ -37,6 +38,7 @@ public function joinAllByTransaction(){
3738
}
3839

3940
public function insertLink($roles, $name, $href, $icon = null){
41+
$href = $this->subFolder . $href;
4042
if($this->dropdown === false){
4143
DB::table('menus')->insert([
4244
'slug' => 'link',
@@ -121,6 +123,16 @@ public function endDropdown(){
121123
*/
122124
public function run()
123125
{
126+
/* Set subfolder
127+
If your url looks like: example.org/sub-folder
128+
then:
129+
$this->subFolder = '/sub-folder';
130+
*/
131+
$this->subFolder = env('APP_URL', '');
132+
if(substr($this->subFolder, -1) == '/'){
133+
$this->subFolder = rtrim($this->subFolder, '/');
134+
}
135+
124136
/* Get roles */
125137
$this->adminRole = Role::where('name' , '=' , 'admin' )->first();
126138
$this->userRole = Role::where('name', '=', 'user' )->first();

resources/views/dashboard/shared/header.blade.php

+15-15
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<div class="c-wrapper">
44
<header class="c-header c-header-light c-header-fixed c-header-with-subheader">
5-
<button class="c-header-toggler c-class-toggler d-lg-none mr-auto" type="button" data-target="#sidebar" data-class="c-sidebar-show"><span class="c-header-toggler-icon"></span></button><a class="c-header-brand d-sm-none" href="#"><img class="c-header-brand" src="/assets/brand/coreui-base.svg" width="97" height="46" alt="CoreUI Logo"></a>
5+
<button class="c-header-toggler c-class-toggler d-lg-none mr-auto" type="button" data-target="#sidebar" data-class="c-sidebar-show"><span class="c-header-toggler-icon"></span></button><a class="c-header-brand d-sm-none" href="#"><img class="c-header-brand" src="{{ env('APP_URL') }}/assets/brand/coreui-base.svg" width="97" height="46" alt="CoreUI Logo"></a>
66
<button class="c-header-toggler c-class-toggler ml-3 d-md-down-none" type="button" data-target="#sidebar" data-class="c-sidebar-lg-show" responsive="true"><span class="c-header-toggler-icon"></span></button>
77
<?php
88
use App\MenuBuilder\FreelyPositionedMenus;
@@ -13,52 +13,52 @@
1313
<ul class="c-header-nav ml-auto mr-4">
1414
<li class="c-header-nav-item d-md-down-none mx-2"><a class="c-header-nav-link">
1515
<svg class="c-icon">
16-
<use xlink:href="/assets/icons/coreui/free-symbol-defs.svg#cui-bell"></use>
16+
<use xlink:href="{{ env('APP_URL') }}/assets/icons/coreui/free-symbol-defs.svg#cui-bell"></use>
1717
</svg></a></li>
1818
<li class="c-header-nav-item d-md-down-none mx-2"><a class="c-header-nav-link">
1919
<svg class="c-icon">
20-
<use xlink:href="/assets/icons/coreui/free-symbol-defs.svg#cui-list-rich"></use>
20+
<use xlink:href="{{ env('APP_URL') }}/assets/icons/coreui/free-symbol-defs.svg#cui-list-rich"></use>
2121
</svg></a></li>
2222
<li class="c-header-nav-item d-md-down-none mx-2"><a class="c-header-nav-link">
2323
<svg class="c-icon">
24-
<use xlink:href="/assets/icons/coreui/free-symbol-defs.svg#cui-envelope-open"></use>
24+
<use xlink:href="{{ env('APP_URL') }}/assets/icons/coreui/free-symbol-defs.svg#cui-envelope-open"></use>
2525
</svg></a></li>
2626
<li class="c-header-nav-item dropdown"><a class="c-header-nav-link" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">
27-
<div class="c-avatar"><img class="c-avatar-img" src="/assets/img/avatars/6.jpg" alt="[email protected]"></div>
27+
<div class="c-avatar"><img class="c-avatar-img" src="{{ env('APP_URL') }}/assets/img/avatars/6.jpg" alt="[email protected]"></div>
2828
</a>
2929
<div class="dropdown-menu dropdown-menu-right pt-0">
3030
<div class="dropdown-header bg-light py-2"><strong>Account</strong></div><a class="dropdown-item" href="#">
3131
<svg class="c-icon mr-2">
32-
<use xlink:href="/assets/icons/coreui/free-symbol-defs.svg#cui-bell"></use>
32+
<use xlink:href="{{ env('APP_URL') }}/assets/icons/coreui/free-symbol-defs.svg#cui-bell"></use>
3333
</svg> Updates<span class="badge badge-info ml-auto">42</span></a><a class="dropdown-item" href="#">
3434
<svg class="c-icon mr-2">
35-
<use xlink:href="/assets/icons/coreui/free-symbol-defs.svg#cui-envelope-open"></use>
35+
<use xlink:href="{{ env('APP_URL') }}/assets/icons/coreui/free-symbol-defs.svg#cui-envelope-open"></use>
3636
</svg> Messages<span class="badge badge-success ml-auto">42</span></a><a class="dropdown-item" href="#">
3737
<svg class="c-icon mr-2">
38-
<use xlink:href="/assets/icons/coreui/free-symbol-defs.svg#cui-task"></use>
38+
<use xlink:href="{{ env('APP_URL') }}/assets/icons/coreui/free-symbol-defs.svg#cui-task"></use>
3939
</svg> Tasks<span class="badge badge-danger ml-auto">42</span></a><a class="dropdown-item" href="#">
4040
<svg class="c-icon mr-2">
41-
<use xlink:href="/assets/icons/coreui/free-symbol-defs.svg#cui-comment-square"></use>
41+
<use xlink:href="{{ env('APP_URL') }}/assets/icons/coreui/free-symbol-defs.svg#cui-comment-square"></use>
4242
</svg> Comments<span class="badge badge-warning ml-auto">42</span></a>
4343
<div class="dropdown-header bg-light py-2"><strong>Settings</strong></div><a class="dropdown-item" href="#">
4444
<svg class="c-icon mr-2">
45-
<use xlink:href="/assets/icons/coreui/free-symbol-defs.svg#cui-user"></use>
45+
<use xlink:href="{{ env('APP_URL') }}/assets/icons/coreui/free-symbol-defs.svg#cui-user"></use>
4646
</svg> Profile</a><a class="dropdown-item" href="#">
4747
<svg class="c-icon mr-2">
48-
<use xlink:href="/assets/icons/coreui/free-symbol-defs.svg#cui-settings"></use>
48+
<use xlink:href="{{ env('APP_URL') }}/assets/icons/coreui/free-symbol-defs.svg#cui-settings"></use>
4949
</svg> Settings</a><a class="dropdown-item" href="#">
5050
<svg class="c-icon mr-2">
51-
<use xlink:href="/assets/icons/coreui/free-symbol-defs.svg#cui-credit-card"></use>
51+
<use xlink:href="{{ env('APP_URL') }}/assets/icons/coreui/free-symbol-defs.svg#cui-credit-card"></use>
5252
</svg> Payments<span class="badge badge-secondary ml-auto">42</span></a><a class="dropdown-item" href="#">
5353
<svg class="c-icon mr-2">
54-
<use xlink:href="/assets/icons/coreui/free-symbol-defs.svg#cui-file"></use>
54+
<use xlink:href="{{ env('APP_URL') }}/assets/icons/coreui/free-symbol-defs.svg#cui-file"></use>
5555
</svg> Projects<span class="badge badge-primary ml-auto">42</span></a>
5656
<div class="dropdown-divider"></div><a class="dropdown-item" href="#">
5757
<svg class="c-icon mr-2">
58-
<use xlink:href="/assets/icons/coreui/free-symbol-defs.svg#cui-lock-locked"></use>
58+
<use xlink:href="{{ env('APP_URL') }}/assets/icons/coreui/free-symbol-defs.svg#cui-lock-locked"></use>
5959
</svg> Lock Account</a><a class="dropdown-item" href="#">
6060
<svg class="c-icon mr-2">
61-
<use xlink:href="/assets/icons/coreui/free-symbol-defs.svg#cui-account-logout"></use>
61+
<use xlink:href="{{ env('APP_URL') }}/assets/icons/coreui/free-symbol-defs.svg#cui-account-logout"></use>
6262
</svg><form action="/logout" method="POST"> @csrf <button type="submit" class="btn btn-ghost-dark btn-block">Logout</button></form></a>
6363
</div>
6464
</li>

resources/views/dashboard/shared/nav-builder.blade.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function renderDropdown($data){
3030
}
3131
?>
3232

33-
<div class="c-sidebar-brand"><img class="c-sidebar-brand-full" src="/assets/brand/coreui-base-white.svg" width="118" height="46" alt="CoreUI Logo"><img class="c-sidebar-brand-minimized" src="assets/brand/coreui-signet-white.svg" width="118" height="46" alt="CoreUI Logo"></div>
33+
<div class="c-sidebar-brand"><img class="c-sidebar-brand-full" src="{{ env('APP_URL') }}/assets/brand/coreui-base-white.svg" width="118" height="46" alt="CoreUI Logo"><img class="c-sidebar-brand-minimized" src="assets/brand/coreui-signet-white.svg" width="118" height="46" alt="CoreUI Logo"></div>
3434
<ul class="c-sidebar-nav">
3535
@if(isset($appMenus['sidebar menu']))
3636
@foreach($appMenus['sidebar menu'] as $menuel)

storage/app/.gitignore

100644100755
File mode changed.

storage/app/public/.gitignore

100644100755
File mode changed.

storage/framework/.gitignore

100644100755
File mode changed.

storage/framework/cache/.gitignore

100644100755
File mode changed.

storage/framework/cache/data/.gitignore

100644100755
File mode changed.

storage/framework/sessions/.gitignore

100644100755
File mode changed.

storage/framework/testing/.gitignore

100644100755
File mode changed.

storage/framework/views/.gitignore

100644100755
File mode changed.

storage/logs/.gitignore

100644100755
File mode changed.

0 commit comments

Comments
 (0)