Laravel 8 works fine with laragon locally with the same code, when I upload the same project in the Cpanel and run it shows the error below. I scrutinized the code and could not find the solution. Included the route file below.
The Error:
Invalid route action: [App\http\Livewire\Logout].
Web.php
<?php
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\UserController;
use App\http\Livewire\Logout;
use App\http\Livewire\Login;
use App\http\Livewire\Register;
Route::group(['middleware' => 'auth'], function() {
Route::get('logout', Logout::class)->name('logout');
Route::get('/', function () {
return view('welcome');
});
});
Route::group(['middleware'=>'guest'], function(){
Route::get('login', Login::class)->name('login');
Route::get('register', Register::class)->name('register');
});
Please suggest. Thanks.
Related
I need to develop a project with subdomains in Laravel 7.28. I'll pass subdomain variable and check whether that user belongs to that particular domain. I have installed Xampp on local. I tried these two ways:
1
Route::domain('{subdomain}.myapp.com')->group(function (){
Route::get('/', 'CRM/HomeController#index')->name('subdomain-index');
});
2
Route::group(['domain' => '{domain}.localhost'], function() {
Route::get('/', 'CRM\HomeController#index')->name('crm.index');
Route::get('login', 'CRM\LoginController#login')->name('crm.login');
Route::post('login', 'CRM\LoginController#postLogin')->name('crm.login.post');
Route::get('register', 'CRM\RegisterController#register')->name('crm.register');
Route::post('register', 'CRM\RegisterController#postRegister')->name('crm.register.post');
Route::get('logout', 'CRM\LoginController#logout')->name('crm.logout');
});
When I type 'demo.localhost' that brings me the same content of 'localhost'. When 'demo.myapp.com' I get 'This site can't be reached' error.
Inside of CRM/HomeController:
<?php
namespace App\Http\Controllers\CRM;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class HomeController extends Controller
{
public function index($subdomain)
{
echo '1';
die();
}
}
Where did I do wrong? I tried the official way and questions from StackOverFlow but I can't see my mistake. Any help?
It's laravel version 5.4 and I'm using api.php routes. Following is one of my route in it:
Route::group(['namespace' => 'Api'], function() {
Route::get('auth/test',function(){
return "asd";
});
});
it's giving error on all routes even if I write route in web.php, it's not even loading home page:
http://localhost/bradforduniversityproject/public/
I have run following command too:
php artisan route:clear
nothing is working just giving NotFoundHttpException whatever i write in URL. Any help what could be the reason. thanks!
Following is my api.php file:
Route::group(['namespace' => 'Api'], function() {
Route::get('auth/test2',function(){
return "asd";
});
Route::post('auth/test','Auth\LoginController#test');
Route::post('auth/login','Auth\LoginController#login');
Route::post('auth/register','Auth\LoginController#register');
Route::post('auth/forgotPassword','Auth\LoginController#forgotPassword');
});
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 5.3 newb here. I want going to localhost:8000 to go to the login page generated by php artisan make:auth.
My routes web.php looks like this by default:
Route::get('/', function () {
return view('welcome');
});
Auth::routes();
Route::get('/home', 'HomeController#index');
This of course brings it to the default Laravel welcome page.
I change it to this:
Route::get('/', function () {
return view('home');
});
Auth::routes();
Route::get('/home', 'HomeController#index');
Which brings up the dashboard saying You are logged in! when no authentication has been done, so that isn't working.
I change it to this and nothing loads at all:
Route::get('/', function () {
Auth::routes();
Route::get('/home', 'HomeController#index');
});
Have tried a few other things and nothing seems to work. Would also like the URI to just be localhost:8000 and not localhost:8000/login or anything like that if possible.
Any suggestions?
About 5 minutes after posting this, I realized I needed to do this:
Route::get('/', function () {
return view('auth.login');
});
Auth::routes();
Route::get('/home', 'HomeController#index');
There is quite a major change between laravel 5.2 from 5.1
My side doesnt redirect to the auth page when the page was trying to be directly accessed.
Route::group(['middleware' => ['web']], function () {
Route::auth();
Route::get('/', 'HomeController#index');
Route::get('projects', 'ProjectController#index');
Route::post('projects', 'ProjectController#create');
Route::get('todo', 'ToDoController#index');
Route::post('todo', 'ToDoController#create');
});
Add auth middleware to your route
Route::get('projects', 'ProjectController#index')->middleware(['auth']);
Or you can add middleware in your controller
public function __construct()
{
$this->middleware('auth');
}