Laravel - view does not work

Asked

Viewed 609 times

1

I’m in trouble: I’m editing a site and Laravel’s view is only working on / and when I put another guy http://localhost/blog/public/Termos she gives as if she had not found codig routes:

Route::get('/', 'SiteController@index');
Route::get('/Contato', 'SiteController@Contrat');
Route::get('/Dicas', 'SiteController@Dicas');
Route::get('/Regulamento', 'SiteController@Regulamento');
Route::get('/Termos', 'SiteController@Termos');
Route::get('/Tutorial', 'SiteController@Tutorial');
Route::get('/Cadastro', 'SiteController@Cadastro');

sitecontroller code:

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class SiteController extends Controller
{
    public function index(){
        return view('/site.Home.index') ;
    }
    public function Contrato(){
        return view('/site.Contrato.index') ;
    }
    public function Dicas(){
        return view('/site.Dicas.index') ;
    }
    public function Regulamento(){
        return view('/site.Regulamento.index') ;
    }
    public function Termos(){
        return view('/site.Termos.index') ;
    }
    public function Tutorial(){
        return view('/site.Tutorial.index') ;
    }
    public function Cadastro(){
        return view('/site.Cadastro.index') ;
    }
}

Error print q speaks paginanot inserir a descrição da imagem aqui

however the article exists: inserir a descrição da imagem aqui

The strange thing is that if I change the location of:

public function index(){
            return view('/site.Home.index') ;
        }

For:

public function index(){
            return view('/site.Termos.index') ;
        }

he finds the page and if I do the same procedure on Route::get and change the command Route::get('/', 'SiteController@index'); for Route::get('/', 'SiteController@Termos'); then he usually finds the stranger who just wants to run the /

  • Enable Debug in your .env so it’s easier to know where the bug is.

  • if it is the APP_DEBUG he already is true

  • I didn’t see the route configured public/Termos in your route file and try to take the bar on Return view('/site.Termos.index') ;deixando apenasReturn view('site.Termos.index') ;`

  • Then try to access with http://localhost/blog/Termos

  • @adventistaam took and continues to find

  • @adventistaam se tentar acesso igual vc falou ele da objeto n encontrado

  • Take the la bar from inside the file index.blade.php of the briefcase Termos in line extends also

  • @adventistaam yes I took left as you said and he continues n finding,and equal informed on my last update if I change place he thinks, he is only finding the pastra / the rest he is not finding

  • You took the bar from both the controller and the view Blade file?

  • Yes, I did as you informed me

  • Has how to show what debug displays?

  • what has in templede1?

  • @adventistaam n I’m managing to give Debugbar he n is returning nothing and tmplede1 only has the body of html and @Yield('body')

  • you have the code on github ?

  • What I’ve noticed is that he’s not even in public function Termos(){ } because if I put the same Return view '/site.Termos.index' in public function Index(){ } it finds file and shows normally

  • try to put only one echo 'Pagina termos'; in the Terms function and try to access

  • as I reported in the comment above he does not want to find the Function terms he is only finding the main Function

  • I’m installing here to do this test

  • mano mo estranho pq igual informi se eu trocar a Return view da Function index() pela Return view da Function Terms ele acha a pagina

  • and if I do the same procedure on Route::get and change the command Route::get('/', 'SiteController@index'); for Route::get('/', 'SiteController@Termos'); then he usually finds the stranger who just wants to run the /

  • You already accessed the . htaccess file in the public folder and placed the line RewriteBase /blog below RewriteEngine On?

  • 'Cause the way I told you here in mine worked

  • @adventistaam put what you spoke Rewritebase /blog and now only of the object n found

  • Checks whether this line in apache httpd.conf is uncommented: LoadModule rewrite_module modules/mod_rewrite.so

  • 1

    I restarted the machine here and Dérrepende worked normally q loco

  • Thanks @adventistaam for the attention you gave me

  • Tamu together! Glad it worked

Show 22 more comments

1 answer

0


Dude, try to stop the php artisan serve and then start it again. And start again. I already had problems and it was the cache, when I created new routes with active serve. If this doesn’t work, clear the configuration caches with :

php artisan cache:clear
php artisan config:clear

Ah, extra tip. Pay attention to your other route : Route::get('/Contato', 'SiteController@Contrat'); You are calling it the Contact url instead of the Contract and when passing to the controller you are looking for a Contrat method instead of a Contract.

Edit: I saw your comment now that you had to restart the machine, so the answer was really cache. I’m glad it worked.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.