I am using laravel 5.4 and trying to get index page, i am using following routes
Route::get('/',
['as' => 'home_page',
'uses' => 'Controller@index']);
and index function in controller looks like this:
public function index()
{
return view('index');
}
But when I visit mydomain.com
, I get a different view than index.blade.php
. and it is fine when I use mydomain.com/?
or on my local server.
I have searched everywhere in my code and in a google, but didn't found anything, any help?
ie: let me know if any further information required.
First make sure you are calling the right controller, and this dont have a specific middleware blocking the acess to your index
method and index.blade.php
is inside view folder.
If all of this is fine try this code on your rotes file:
Route::get('', function () {
return view('index');
})
Try this. First use the make:controller Artisan command to create a controller file. let's say it is homeController.
php artisan make:controller homeController
Then in the homeController file write your code to get the view.
<?php
namespace App\Http\Controllers;
class homeController extends Controller
{
public function index()
{
return view('index');
}
}
Then define a route to this controller.
Route::get('/', 'homeController@index');
For more information please refer https://laravel.com/docs/5.5/controllers
There was a cached view saved on my server, I used php artisan cache:clear
and it got fixed. Thank you everyone for the support.