I created a Laravel app with a basic master.blade.php, header & footer and then my home.blade.php.
In my routes.php, I have:
Route::get('/', function () {
return view('home');
});
This was working fine until I ran the php artisan make:auth command. Now I have this in my routes:
Route::auth();
Route::get('/home', 'HomeController#index');
And my previous home page I created is now using the new views that it auto created.
What's the correct way to get back to my previous home design?
Laravel docs says that only run it on fresh installation. You did not. Simple.
If you are using git, just revert to an earlier version.
Maybe you can get something using file recovery tools too.
I don't think there is a clean general solution for you, sorry.
Related
I have some issues with Laravel. I called php artisan route:cache and then the issues began. For example, the Auth routes (login etc.) can be called even if the User is logged in. Then the caching command seems to not clearing the routes. I noticed it because I put my Auth routes in the middleware guests because of the rendering of the Auth routes. After I ran route: clear it worked.
Also, the 404 routing doesn't work since that, because if I call a route that doesn't exist, then the Symfony Framework throws an error:
Symfony\Component\Routing\Exception\ResourceNotFoundException
That's my web.php:
Route::get("/installer","install\InstallController#index");
Route::group(["middleware"=>"guest"],function(){
Auth::routes();
Route::post("login","Auth\Logincontroller#authenticate");
});
Route::group(["middleware" => "auth"], function () {
Route::get("/logout","Auth\LoginController#logOut");
Route::get('/', "dashboard\DashboardController#index");
});
Also, the installer route doesn't work. I will always get redirected to localhost/dashboard (even if I change the route name). My domain for the Laravel is called raptor.debug, so I don't know why it's redirecting to localhost.
Can someone point out what I did wrong or is this a bug?
As Anas Bakro pointed out, the command php artisan route:cache will brick the app, when the folder of the controllers are lowercased.
So I've downloaded Laravel 5.5, and I ran the following command
in my terminal. php artisan make:auth and when I reloaded Laravel, the links for Login and Register show up but when I click them, it says Not Found.
I've tried resetting artisan and deleting my tables, and re-migrating artisan too, but none of them work.
php artisan make:auth
And heres my web.php file.
Route::get('/', function () {
return view('welcome');
});
Route::get('/post', 'PostController#index');
Auth::routes();
Route::get('/home', 'HomeController#index')->name('home');
Auth::routes();
Route::get('/home', 'HomeController#index')->name('home');
Have you checked your project's directory tree after executing it?
Did you run the migrations?
If you did all that it should scaffold all of the routes and views you need for authentication. But if it still does not work properly, then you might have to uninstall Laravel and install a fresh distro.
Can you add your web.php file under the routes directory please ?
It's probably a route problem.
Thank you.
It is because of anchor tag is not work...it may be some syntex error or spelling mistake
maybe ragister.blade.php have some problem
I am having a problem with accessing the Auth::user() in a Laravel package routes file.
I am creating a package for Laravel (using 5.8.9). The package has its own routes in a route file which is being added correctly.
I have created an identical route in the main test site and the package. I am using composer 'path' to symlink the package into the test site which is on Homestead that I'm using on a windows 10 computer.
The route is simple and I'm just checking to see if a user is logged in, which it is.
Route::get('/home', function () {
dd(Auth::check());
});
In the main site routes file the check is returning true as expected. When commented out and allowing the route file in the package to handle it we get a return of false.
I noticed it as was getting an error when trying to run middleware on the package and after some investigating found that the package is not registering the user as being logged in.
Any ideas? Is it a problem because I'm using the path on composer to symlink?
EDIT: OK I've ruled out the symlink being the problem by creating a private repo and importing it. So its now in the vendor as a normal imported package but still getting the same issue.
EDIT2: I just tried to pull a user in the package routes file by just doing a simple
Route::get('/home', function () {
$user = \App\User::find(1);
dd($user);
});
And get null does anyone know if its possible to access the user/core laravel models in a package or is it disabled or a problem with the load order?
I managed to resolve it, if you use routes that require auth in your packages then you need to include the web middleware. If you do not include the web middleware then you are not loading some of the functionality that the main framework will load, like sessions.
And if you don't have sessions then obviously you wont be able to retrieve logged in users.
So to get it working you would change the code to
Route::get('/home', function () {
$user = \App\User::find(1);
dd($user);
})->middleware(['web']);
I am using Ubuntu 16.04 and installed Laravel 5.3 on desktop/Laravel/test directory. I have created a test.blade.php file in resources/view directory. I have also created routes.php in app/Http directory and added following code:
Route::get('/', function(){
return view('test');
});
When I enter command in terminal: php artisan serve and go to http://localhost:8000 url in browser, it shows default page of laravel after installation. Why it is not showing view I have created? I have also tried writing following code in routes.php:
Route::get('/', function(){
echo "Test";
})
But still it doesn't work. Is there anything I am missing?
Reference
By default, fresh Laravel 5.3 applications contain two HTTP route
files in a new top-level routes directory. The web and api route files
provide more explicit guidance in how to split the routes for your web
interface and your API.
The routes.php is moved to different folder in Laravel 5.3. Update routes/web.php file.
From the Laravel Documentation 5.3
The routes directory contains all of the route definitions for your application. By default, three route files are included with Laravel: web.php, api.php, and console.php.
The routes.php was there in previous version. But in laravel 5.3 the routes.php is moved to routes/web.php as Saumini Navaratnam said.
I am new to laravel.
I was in middle of my project. I googled for login validation in laravel 5.
I found this command
php artisan make:auth
it Created several classes and also modified my welcome.blade.php
there was several code in welcome.blade.php.
Now How to rollback effects of this command.
Please Help.
Look at the make:auth command source code to understand what exactly files this command added or changed and revert changed back.
manually you have to remove following files
auth/login.blade.php
auth/register.blade.php
auth/passwords/email.blade.php
auth/passwords/reset.blade.php
layouts/app.blade.php
home.blade.php
Go to routes/web.php, delete the created routes by the command make:auth. Remove these two lines and your project will work fine as before.
Auth::routes();
Route::get('/home', 'HomeController#index');
The answer is NO.
There is no way you can rollback make:auth command as yet in laravel..
You can remove auth manually be removing auth from app controller and and auth route. And if you were lucky enough to have welcome file opened in some IDE then there was a chance of ctrl+z bcause IDEs keep back in memory,., but other then that there is no way retrieving backup the data.
we can simply remove below line form wep.php routes folder.
Auth::routes();
Route::get('/home', 'HomeController#index')->name('home');
you can also remove the view files: like auth folder ,app.blade.php, home.blade.php