When the user accesses "http://proj.test/" instead of getting the homepage I get:
Sorry, the page you are looking for could not be found.
But if the user accesses "http://proj.test/home" it works.
Also when the user accesses "http://proj.test/conference/create" instead of appear the page with the form to create a conference it appears:
View [app] not found. (View: /Users/johnw/projects/proj/resources/views/conferences/create.blade.php)
Do you know where can be the issue? Should be something about the links or routes but I don't know where is the issue.
Links that I'm using
<a class="logo" href="{{route('home')}}">Homepage</a>
Create Conference
Login
Logout
Register
Routes:
Route::group(['prefix' => '', 'middleware' => 'auth'], function(){
Route::post('/conference/store', [
'uses' => 'ConferenceController#store',
'as' => 'conference.store'
]);
Route::get('/conference/create', [
'uses' => 'ConferenceController#create',
'as' => 'conference.create'
]);
});
Auth::routes();
Route::get('/home', 'HomeController#index')->name('home');
When the user accesses "http://proj.test/" instead of getting the homepage I get:
Sorry, the page you are looking for could not be found.
You have not defined any route for this URL
You can do
...
Route::get('/', 'HomeController#index');
Route::get('/home', 'HomeController#index')->name('home');
...
Very simple answer - you need a Route::get('/', ...) route.
Add this to your Routes instead:
Route::group(['middleware' => ['guest']], function(){
Route::get('/', 'WelcomeController#index');
// WelcomeController is my own example, yours will differ...
});
This way it'll check to see if there's an auth or not and will redirect accordingly.
Related
I have a vendor routes in my routes folder
Route::group(['prefix' => 'vendor', 'middleware' => ['auth:vendor']], function () {
Route::get('/dashboard', 'Vendor\VendorController#dashboard')->name('vendor.dashboard')-
>middleware('bannedVendor');
Route::get('/logout/{id?}', 'Vendor\LoginController#logout')->name('vendor.logout');
});
And whenever i try accessing any vendor routes on my browser my package(vendor) folder shows up instead.
How can i resolve this issue?
I am new in laravel 5.2. I want to make dashboard for admin but i do not understand how to make it. I did copy all controller files in admin folder and also copied view folder in admin folder.
I did try some code which is mention below:-
Route::group(array('namespace'=>'Admin'), function()
{
Route::get('/admin', array('as' => 'admin', 'uses' => 'UserController#index'));
Route::get('/admin/register', array('as' => 'register', 'uses' => 'UserController#register'));
Route::get('/admin/login', array('as' => 'login', 'uses' => 'UserController#login'));
});
but now I want to show all controller files under admin like:-
localhost:8000/admin/users
If you want to use all route of admin on localhost:8000/admin.
You should use route group and add prefix on it, like that
Route::group(['prefix' => 'admin/'], function () {
Route::get('users', function () {
// Matches The "/admin/users" URL
});
Route::get('login', function () {
// Matches The "/admin/login" URL
});
.......
});
Read more at this doc https://laravel.com/docs/5.2/routing#route-groups
I hope this could help you.
I've been working on an app that initially didn't use middleware. Later on, I decided to add middleware and had to change my routes from something like:
Route::get('admin/poems', array('as' => 'poems', 'uses' => 'PoemsController#poem'));
to
Route::get('admin/poem', ['middleware' => 'auth', 'uses' => 'PoemsController#poem']);
Now the disadvantage is that I had been redirecting to this route (poems) several times and adding middleware as indicated will require me to go through all my code and change the name of the route in the redirect.
How do i solve this problem?
Thanks for any help.
You don't need to lose the name of your route, the array will still accept it along with your middleware.
Just add it in to look like so:
Route::get('admin/poem', ['middleware' => 'auth', 'as' => 'poems', 'uses' => 'PoemsController#poem']);
This way you don't need to go through and rename your routes anywhere and can still protect it with auth middleware.
try put middleware to a group route
Route::group(['middleware' => 'auth'], function () {
Route::get('/', function () {
// Uses Auth Middleware
});
Route::get('user/profile', function () {
// Uses Auth Middleware
});
});
If I type my website url in browser as www.test.com/ then it redirects to www.test.com/home. But I want to see the url in browser as www.test.com only.
routes.php
Route::get('/', array('uses' => 'HomeController#home', 'as' => 'home'));
Route::get('home', array('uses' => 'HomeController#home', 'as' => 'home'));
Try this in your route file:
Route::get('/', 'Admin\HomeController#index');
and remove the extra home route.
See, if that helps.
Route::get('/', array('uses' => 'HomeController#home', 'as' => 'home'));
Keep this route only and remove the next route
It will work as you are expecting then
I have the following named route in routes.php:
Route::get('/', 'DefaultController#index', array('as' => 'home'));
Then, I try to get a link to the route in another view (404.blade.php), based on docs:
Go to homepage
However, the page with the code above thows this: Error in exception handler: Route [home] not defined. I tried using simply route('home') as well.
What am I missing?
The syntax for named routes is a bit different
Route::get('/', array('as' => 'home', 'uses' => 'DefaultController#index'));