Reputation: 13
I am probably miss something, but can't figure out problem myself.
I am getting white screen (no logs in storage/logs and 200 code in Apache logs). I think that return View::make() is not passing view string.
In routes.php
Route::get('/home', array('as' => 'home', 'uses' => 'HomeController@index'))->before('guest');
In filters.php
Route::filter('guest', function(){
if (Auth::check() === true) {
return Redirect::route('dashboard')->with('flash_notice', 'You are already logged in!');
}});
In HomeController.php
class HomeController extends BaseController {
public function index()
{
return View::make('login');
}}
In views/login.blade.php
@extends('layouts.login')
In views/layouts/login.blade.php just HTML
Once I change return View::make('login'); to echo View::make('login'); I get rendered view.
I did install same codebase previously and it worked (yes, it was Laravel 4 as well), so I wonder this somehow related to new library versions.
Thank you for your help.
Upvotes: 0
Views: 1056
Reputation: 7460
Create a master file base.blade.php inside your views/layouts folder:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<title>Signin</title>
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css">
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-theme.min.css">
<script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
<style>
body {
background-color: #EEEEEE;
padding-bottom: 40px;
padding-top: 40px;
}
.form-signin {
margin: 0 auto;
max-width: 330px;
padding: 15px;
}
.form-signin .form-signin-heading, .form-signin .checkbox {
margin-bottom: 10px;
}
</style>
</head>
<body>
<div class="container">
@section('maincontent')
@show
</div>
</body>
</html>
And then in your login.blade.php:
@extends('layouts.base')
@section('maincontent')
<form class="form-signin" action="/login" method="POST" >
@if ($errors->first('login'))
<div class="alert alert-danger" >
{{$errors->first('login')}}
</div>
@endif
@if ($errors->first('password'))
<div class="alert alert-danger" >
{{$errors->first('password')}}
</div>
@endif
@if(Session::has('flash_notice'))
<div class="alert alert-danger" >
{{Session::get('flash_notice')}}
</div>
@endif
@if(Session::has('flash_success'))
<div class="alert alert-success" >
{{Session::get('flash_success')}}
</div>
@endif
<h2 class="form-signin-heading">Please sign in</h2>
<input type="text" class="form-control" placeholder="Login" name="login" autofocus>
<input type="password" class="form-control" placeholder="Password" name="password" >
<label class="checkbox"></label>
<button class="btn btn-lg btn-primary btn-block" type="submit">Sign in</button>
</form>
@stop
Upvotes: 1
Reputation: 7460
Change Route:
Route::get('home', array('as' => 'home', 'before' => 'guest', 'uses' => 'HomeController@index'));
Upvotes: 0