laravel 8 does not set homepage like in 7x version - php

I would like to set the home page of laravel 8 as that of laravel 7x.
to do this I wrote the following route:
Route::view('/', 'welcome', [PollController::class, 'element']);
I just keep seeing the following page:

Route::get('/', [PollController::class, 'element'], function () {
return view('welcome');
});
I renamed the file resources/views/welcome.blade.php in resources/views/welcome.blade.php and it worked

Related

PHP Laravel route after installation

I installed new laravel project("Starter") and want to view the 'welcome' page by putting this URL.
http://localhost/starter/
The page ran fine when the route is the following.
Route::get('/', function () {
return view('welcome');
});
However, when I write any thing after the (/)...
Route::get('/test', function () {
return view('welcome');
});
And view it by URL:
http://localhost/starter/test
The page doesn't work and shows...
404
Not Found
Any ideas?
(s) in word (starter) in the URL, shoud be UpperCase (Starter) as the name of Laravel project

Change the route in Aimeos Laravel

I am using Aimeos e-commerce on a Laravel site, I want to change the store route to /shop but I get an the browser doesn't open a page I do it as follows
Route::get('/shop', function () {
return redirect('shop');
})->name('shop');
but when I make on "/" main page it displays perfectly. How to change its route?
Use this in your route/web.php file:
Route::get('/', function () {
return redirect('shop');
});
See https://github.com/aimeos/aimeos/blob/master/routes/web.php

Laravel 5.3 set homepage as login screen

How do I set the homepage (/) to the login screen in Laravel 5.3?
I have a routes file :
Route::get('/', function () {
return view('welcome');
});
I have set up the basic auth scaffolding with the command php artisan make:auth and have set up my db tables too.
But I'm struggling to understand how to set the homepage to always go to the login screen if the user is not authenticated? Surely this is just me being stupid right?
I just needed to specify the middleware('auth') for my route:
Route::get('/', function () {
return view('home');
})->middleware('auth');
Route::get('/home', 'HomeController#index');
This way if you're not logged in it will redirect to login automatically.
You can do it like this:
Route::group(['middleware' => 'auth'], function () {
Route::get('/', function () {
return view('welcome');
});
});
Just put all the routes that needed authentication inside that middleware group.
in laravel in general you can change the url view path to what you want as example
Route::get('/', function () {
return view('auth.login');
});
In laravel 5.4 you can modify the route as
Route::get('/', 'Auth\LoginController#showLoginForm');

Laravel Homestead Routing : InvalidArgumentException in compiled.php : View [****] not found

After getting my Laravel Homestead up and running, I'm facing a new problem.
Even after some googling, I can't find a solution for setting up routes in Laravel Homestead.
Here is my routes.php (I created files like in the comments) :
<?php
// ===============================================
// STATIC PAGES ==================================
// ===============================================
// show a static view for the home page (app/views/home.blade.php)
Route::get('/', function()
{
return View::make('home');
});
// about page (app/views/about.blade.php)
Route::get('about', function()
{
return View::make('about');
});
// work page (app/views/work.blade.php)
Route::get('work', array('as' => 'work', function()
{
return View::make('work');
}));
Route::get('users', function()
{
return View::make('users');
});
Thank you in advance for any piece of advice.
In Laravel5 the views are located in
resources/views
and not in app/views
Place all your views to resources/views and it should work.
You get the welcome page because it is shipped by default in Laravel.

Unable to route blade file in Laravel 4

I have problem in my Laravel 4 project. I want to start using blade template but all I got is error when loading project.
I have an index.php view and this is my routes.php file:
Route::get('/', function()
{
return View::make('index');
}
And all this works like a charm. But alter I change my view file name to index.blade.php nothing works anymore.
I have tried to change my routes.php file to:
Route::get('/', function()
{
return View::make('index.blade');
}
But no luck.
What I have been missing?
Try setting up your local environment to get more detailed error messages.
http://laravel.com/docs/configuration#environment-configuration
You should be good to go with:
Route::get('/', function()
{
return View::make('index');
});
Notice the closing parenthesis and semicolon, which is the only thing that I notice missing from your code.

Categories