Support the ongoing development of Laravel.io →
Requests Views
Last updated 2 years ago.
0

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.

Last updated 9 years ago.
0

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 /.

0

Show us your PagesController file.

0

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.

Last updated 9 years ago.
0
Route::get('/',function(){
    return View::make('home');
});

if you just want to return a view, then the controller is not even worth to use.

Last updated 9 years ago.
0

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.

0

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.

0

Sorry, this does not make sense to me.

What difference is there if my name my "/" controller as home or index?

0

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.

Last updated 9 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Purus purus Joined 19 Jul 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.