Laravel route group issue (blank page) - laravel

config: laravel 5.5
web.php
Route::group([
// 'middleware' => ['auth', 'is_admin'],
'namespace' => 'Admin',
'prefix' => 'admin',
],
function () {
Route::get('/', function(){
return 'admin';
});
Route::get('/pages', 'AdminController#pages')->name('admin_pages');
});
php artisan route:list
http://prntscr.com/moltmg
but get http://prntscr.com/moluky empty page
I don’t know what the problem is, I’m registering the path, I’ll use group, but I’m getting a blank page, no error, nothing. Other path work fine, also if I register a path in a group, for example:
admin / dashboard
everything is fine, only this one does not work.

Try running these commands.
php artisan config:clear
php artisan cache:clear
composer dump-autoload -o
if still not working.
provide 777 permission to storage and bootstrap/cache folders.

you need to add the route::get in your group.
this is an example that can help you :
Route::group(['prefix' => 'admin', 'middleware' => 'auth'], function()
{
//All the routes that you have :
Route::get('/pages', 'AdminController#pages')->name('admin_pages');
});
Hope this helps :) good luck

I apologize for the disturb, I am an idiot and created the "admin" folder in the "public" folder.

Related

404 Page not found in laravel

I'm trying to add a new page in laravel. I've checked the index page, controller and I keep getting a 404 error.
web.php
Route::group(
['namespace' => 'Admin', 'prefix' => 'admin', 'as' => 'admin.', 'middleware' => ['role:admin']],
function () {
Route::group(
['middleware' => ['licence-expire']],
function () {
Route::resource('curriculum', 'AdminCurriculumController');
Controller
public function index()
{
$this->curriculum =Curriculum::count();
return view('admin.curriculum.index', $this->data);
}
By using prefix all routes in the group get the admin/ prefix. The curriculum resource can then be found at localhost/admin/curriculum/. You can list all available routes by issuing php artisan route:list
If the route doesn't show up in php artisan route:list try clearing the cache: php artisan route:clear. If this doesn't work try adding a test url to ensure the cache is cleared:
Route::get('/', function () {
return view('welcome');
});
Try
php artisan cache:clear
You have probably cached your routes, so you can't add any more because Laravel will now be based on the cached file and not on the web.php file you are updating

Route issue in Laravel 5.7.2

I have just downloaded Laravel 5.7.2 project and found an issue below.
Below line does not work in Laravel 5.7.2 and gives 404
Route::get('/login',
array(
'uses' => 'Annonymous\Web\Auth\Login\LoginController#showLoginForm',
'as' => 'showLoginForm'
)
);
Below works in Laravel 5.7.2
Route::get('/', function () {
return view('Annonymous.welcome');
});
Below code works in Laravel 5.6.16 and 5.6.33
Route::get('/login',
array(
'uses' => 'Annonymous\Web\Auth\Login\LoginController#showLoginForm',
'as' => 'showLoginForm'
)
);
Any idea why the same code does not work in 5.7.2 ?
I can confirm that the route is present in the route list.
Since your project is not in root of Localhost
Try 'php artisan serve'
It Will Work

Routes are not working properly

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.

laravel-localization methodnotallowed while posting a form

I'm getting MethodNotAllowedHttpException in RouteCollection.php line 218:
when i'm posting form within larave-localization route group.
Here is my localized route group:
Route::group([
'prefix' => LaravelLocalization::setLocale(),
'middleware' => [ 'localeSessionRedirect', 'localizationRedirect' ] ], function() {
Route::post('/offerselect', 'SearchController#getCarList');
Route::get('/', 'PageController#index');
});
I have a form inside index.blade php and it posts to /offerselect
but when i post it i get methodnotallowed exception. if i place the post outside of group it works without localization....
check
php artisan routes
to see if you're routes are defined correctly.
update: is that your whole routes.php?

Laravel middleware detected but not executed

I have a middleware which works fine when defined as a global middleware in Kernel.php. However, I want it to be applied only to specific routes, so I do this:
Route::group(['prefix' => 'myapi/', 'middleware' => 'api'], function(){
});
Calling php artisan route:list shows that the middleware is detected correctly. However, it does not get executed (I know this because even purposely placing an error in the file does not do anything).
...
protected $middlewareGroups = [
...
'api' => [
'throttle:60,1',
\App\Http\Middleware\CORSMiddleware::class,
],
];
When the middleware is set as global, it does not get listed by route:list. Also, purposely specifying a wrong middleware name in routes.php does not throw any error.
EDIT:
Logging shows that the middleware is executed for all GET ressource routes, but not for POST/PUT/DELETE.
I believe middleware has to be placed inside an array when adding it to a group - that will cause it to trigger and give you the expected result:
Route::group(['prefix' => 'myapi/', 'middleware' => ['api']], function(){
});

Resources