I'm trying to create a custom admin page and Menu in Laravel Voyager.
This is the error that I'm getting.
ErrorException (E_ERROR)
No hint path defined for [voyager ]. (View: /Users/jake/code/DS/resources/views/vendor/voyager/orders/order.blade.php)
This is my web.php file
Route::get('/', function () {
return view('welcome');
});
Route::group(['prefix' => 'admin'], function () {
Voyager::routes();
});
Route::get('/admin/orders', function () {
return view('vendor/voyager/orders/order');
});
This is my resources/views/vendor/voyager/orders/order.php
#extends ('voyager::master')
#section('content')
<h1>Hello There</h1>
#stop
When I add TCG\Voyager\VoyagerServiceProvider::class, to app.php it displays the page but other things like $dataTypeContent don't work. I'm using Laravel 5.6 whereby I thought Voyager is auto-discovered. Am I doing something wrong?
Any Help would be great.
Thanks, Jake.
I believe the error is coming from this route:
Route::get('/admin/orders', function () {
return view('vendor/voyager/orders/order');
});
Try changing the return to:
return view('voyager::orders.order');
Another thing, resources/views/vendor/voyager/orders/order.php is missing the blade portion, so resources/views/vendor/voyager/orders/order.blade.php
Related
My controllers which are HomeController and BlogController in Admin folder. My views like:
/admin
index.blade.php
/blog
index.blade.php
I want to call /admin0admin url to /resources/views/admin/index.blade.php.
I want to call /admin0admin/blog url to /resources/views/admin/blog/index.blade.php
Here how i call in view:
<a href="{{ route('admin0admin.blog') }}" class="br-menu-link">
And my routes like:
Route::group(['namespace' => 'Admin', 'prefix' => 'admin0admin'], function () {
Route::get('/', 'HomeController#index')->name('index');
Route::group(['prefix' => 'blog'], function () {
Route::get('/', 'BlogController#index')->name('index');
});
});
And my BlogController index method:
return view('admin.blog.index');
I got an 404 not found error.
Route [admin0admin.blog] not defined
Laravel Version is : 5.6.*
You need to name the route admin0admin.blog, not index. prefix does not affect names of routes, so you need to write it out.
I have a path in Laravel it is like subdomain.mydomain.com/admin/login
I am trying to call
subdomain.mydomain.com and need to get the login page straight.
Currently, it's not working
This is the function I am using in routerserviceprovider.php
protected function mapAdminRoutes()
{
Route::middleware('subdomain.mydomain.com')
->prefix('admin')
->namespace($this->namespace)
->group(base_path('routes/admin.php'));
}
and in admin.php there is a resource group shows like this:
Route::group(['prefix' => 'admin', 'namespace' => 'Admin'], function() {
//Login Routes...
Route::view('login','admin.login');
});
can anyone help with this?
Add following route
Route::get('/',function(){ return view('login.index'); })->name('admin.login');
i hope it helps
How to get an id of the user?
app/routes/web.php
Route::group(['middleware' => 'auth'], function()
{
var_dump(Auth::user());
}
It returns null.
Simple things made difficult.. Also there is no reliable explanation
How to handle this?
You have not defined any route, try this instead:
Route::group(['middleware' => 'auth'], function () {
Route::get('/', function () {
dd(Auth::user());
});
});
Change the '/' to what ever you like, does that work for you?
I have following route group for admin panel
Route::prefix('admin')->group(function (){
.
.
.}
I want to wrap this route to a new route e.g asda12asda
so that old behavior :
/admin/users
is changed to :
/asda12asda/users
not allowing old route. I don't want to change it internally from the system and want to find some efficient Laravel way to achieve it.
Redirect the old route to a new route
Route::prefix('admin')->group(function (){
Route::any('login', function () {
// Redirect to new route
redirect()->route('new route');
});
});
by creating a new route and mapping it accordingly
Route::prefix('asda12asda')->group(function () {
Route::any('login', function () {
// Do whatever you were about to do
})->name('new route');
});
If you are using Laravel 5.4 then you can add a new route file. Assume your route name is
adsp.php then add it to RouteServiceProvider.php like this.
protected function mapApiRoutes()
{
Route::group([
'middleware' => 'web',
'namespace' => $this->namespace,
], function ($router) {
require base_path('routes/adsp.php.php');
});
}
I start a new laravel project make composed by two pages, I created the pages under the app/view directory and this is my route.php file:
Route::get('/', function()
{
return View::make('hello');
});
Route::get('welcome', function()
{
return View::make('welcome');
});
Route::any('signup', function()
{
return View::make('signup');
});
I can access to the pages signup by taping the link directly in the browser and also when I run artisan routes it shows me the routes that I created.
in the welcome.blade.php when I add the line
{{link_to_route('signup')}}
and reload the page I have this error
ErrorException
Route [signup] not defined. (View: C:\wamp\www\atot\app\views\welcome.blade.php)
how can I solve this problem?
Try this instead:
Route::any('signup', [
'as' => 'signup',
function() {
return View::make('signup');
}
]);
Your problem was that you didn't use a named route.
If you want, you can read more about it here: http://laravel.com/docs/routing#named-routes
Link_to_route is a method that generates a url to a given named route, so to make it work you can name each of your routes and then it will work
link_to_route('route.name', $title, $parameters = array(), $attributes = array());
In routes.php update the following
Route::get('/', array('as'=>'home', function()
{
return View::make('hello');
}));
Route::get('welcome', array('as'=>'welcome', function()
{
return View::make('welcome');
}));
Route::any('signup', array('as'=>'signup', function()
{
return View::make('signup');
}));
Then you can generate the following routes:
{{link_to_route('home')}}
{{link_to_route('welcome')}}
{{link_to_route('signup')}}
You should use either:
{{ link_to('signup') }}
Or declare the route using a name
Route::any('signup', array('as' => 'signup', function()
{
// ...
}));
The link_to_route helper function only works with a named route which accepts a route name in the first argument.