the "home" function in your PagesController.
It should say
public function home()
{
//your code
return Redirect::to('/');
}
I guess, it is redirecting the user to your "home" view.
dukejib said:
the "home" function in your PagesController.
It should say
public function home() { //your code return Redirect::to('/'); }
I guess, it is redirecting the user to your "home" view.
Thanks for your time on your answer. But this is going on a infinite loop as the root is already mapped to home controller and inside that we are again redirecting to /.
This is the PagesController section.
public function home()
{
//your code
return view('home');
}
I have a view file caller home.blade.php and it works correctly when I first go to the application.
Please let me know if you need any other information. This is my first ever Laravel project. so sorry for silly questions.
Route::get('/',function(){
return View::make('home');
});
if you just want to return a view, then the controller is not even worth to use.
Hi,
It still redirects to the /home URI.
I am really working on a bigger project and I need to add business logic to the controller. So this might not be a perfect solution.
Please correct me if I am wrong.
You are asking laravel to show view('home') in PagesController@home. It is doing what you are asking it to do.
You need 2 views , call the one which you want to show on "/" = index.blade.php and show it in your pagescontroller like
public function index()
{
return view('index'); //using 5.0 laravel
}
public function home()
{
return view('home');
}
and in route
Route::get('/',PagesController@index);
Rouet::get('home',PagesController@home);
Purus said:
This is the PagesController section.
public function home() { //your code return view('home'); }
I have a view file caller home.blade.php and it works correctly when I first go to the application.
Please let me know if you need any other information. This is my first ever Laravel project. so sorry for silly questions.
Sorry, this does not make sense to me.
What difference is there if my name my "/" controller as home or index?
use the provided code in seperate files , i am sure the coding will help you understand why your url is showing home.
Route.php
Route::get('/','MyController@index');
Route::get('home','MyController@home');
Route::get('some','MyController@some');
MyController.php
<?php namespace App\Http\Controllers;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class MyController extends Controller {
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
//
return 'Index Page';
}
public function home()
{
return 'Home Page';
}
public function some()
{
return \Redirect::to('/'); //This will redirect to Route::get('/','MyController@index'); in routes file
}
}
Try the above code and check it against your own. Hopefully, Its just routing mess.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community