Skip to content

Commit

Permalink
Fix #5038
Browse files Browse the repository at this point in the history
  • Loading branch information
z-song committed Oct 21, 2020
1 parent a2ef145 commit ee897f7
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 5 deletions.
2 changes: 1 addition & 1 deletion resources/views/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
@endif

<script src="{{ admin_asset('vendor/laravel-admin/require.js') }}"></script>
<script src="{{ admin_asset('_require_config') }}"></script>
<script src="{{ admin_route('require-config') }}"></script>
</head>

<body class="hold-transition {{join(' ', config('admin.theme.layout'))}} {{ config('admin.theme.accent') ? 'accent-'.config('admin.theme.accent') : '' }}">
Expand Down
2 changes: 1 addition & 1 deletion src/Form/Field/BelongsToRelation.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ protected function getLoadUrl()
$selectable = str_replace('\\', '_', $this->selectable);
$args = [intval($this instanceof BelongsToMany)];

return route(config('admin.route.as') . 'handle_selectable', compact('selectable', 'args'));
return admin_route('handle_selectable', compact('selectable', 'args'));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Form/Field/ValuePicker.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ protected function getLoadUrl()

$args = [$this->multiple, $this->column];

return route(config('admin.route.as') . 'handle_selectable', compact('selectable', 'args'));
return admin_route('handle_selectable', compact('selectable', 'args'));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Table/Displayers/BelongsTo.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ protected function getLoadUrl($selectable, $multiple = 0)
$selectable = str_replace('\\', '_', $selectable);
$args = [$multiple];

return route(config('admin.route.as') . 'handle_selectable', compact('selectable', 'args'));
return admin_route('handle_selectable', compact('selectable', 'args'));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Table/Displayers/Expand.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@ protected function getLoadUrl()
{
$renderable = str_replace('\\', '_', $this->renderable);

return route(config('admin.route.as') . 'handle_renderable', compact('renderable'));
return admin_route('handle_renderable', compact('renderable'));
}
}
15 changes: 15 additions & 0 deletions src/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -408,3 +408,18 @@ function admin_user()
return \Encore\Admin\Facades\Admin::user();
}
}

if (!function_exists('admin_route')) {
/**
* @param $name
* @param array $parameters
* @param bool $absolute
* @return mixed
*/
function admin_route($name, $parameters = [], $absolute = true)
{
$name = config('admin.route.as', '').$name;

return app('url')->route($name, $parameters, $absolute);
}
}

0 comments on commit ee897f7

Please sign in to comment.