Request in url with laravel

0

I'm trying to start in Laravel , and I'm having problems with requests , when I only do request like localhost:8000/hoteis everything works it fetches the page and works perfectly, but if% it is not working, the route file is as follows:

Route::get('/hoteis', 'HotelCrontroller@listarHoteis');
Route::get('/hoteis/{nome}', 'HotelCrontroller@mostraHotel');

My controller is programmed like this:

namespace App\Http\Controllers;
use Illuminate\Support\Facades\DB;
use Request;

class HotelCrontroller extends Controller
{
    public function listarHoteis()
    {
        //DB::select('Aqui vem a query');
        $hoteis =  'Aqui vem os hoteis.';
        return view('hotel')->with('hoteis', $hoteis);
    }

    public function mostraHotel(){
       $nomeHotel = Request::route('name');
       return view('detalhehotel')->with('hotel', $nomeHotel);
    }
}

and on my page it looks like this:

@extends('index')
@section('conteudo')
<?php
    $hoteis = $hotel;

    echo $hoteis;
?>
@stop

What will be the problem? For testing I tried to go straight to the page and it worked perfectly.

  

I found that there might be something with css or something, since all the pages I write localhost:8000/hoteis/nomedohotel it has the 404 error page stylized but when I put /algo it appears the same page but without being stylized.

     

I have seen that the files he is getting are thus /algo/algo so this is why the whole style is coming in the wrong way, how do he only load http://localhost:8000/aa/css/app_2.min.css . This will work what I want.

    
asked by anonymous 30.07.2016 / 01:17

2 answers

1

In this case, you must be inserting the assets in the wrong way. When referring to the path of an asset, you should use the asset facade in your template like this: {{asset ('css / app_2.min.css')}}. You are probably using the current url, so you are adding the current route in the CSS path.

    
30.07.2016 / 02:42
1
  

but if you do localhost: 8000 / hotels / hotel name it is not working

Can you get information about the error that appears? However, make sure you have .htaccess set up.

At project root:

<IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteCond %{REQUEST_URI} !^public
  RewriteRule ^(.*)$ /public/$1 [L]
</IfModule>

In the / public folder

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)/$ /$1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>
    
31.07.2016 / 20:14