vendredi 25 décembre 2015

Laravel 4 - unable to show the page

I tried to redirect to the 'login' page but the page is showing blank. Please see the following coding on the respective pages:

On routes.php:

Route::resource('users','UserController'); Route::get('/users/login', array('as' => 'users.login', 'uses' => 'UserController@getLogin'));

On UserController.php:

<?php

class UserController extends \BaseController {

/**
 * Display a listing of the resource.
 *
 * @return Response
 */
public function index()
{
    $users = User::paginate(10);
    return View::make('users.index', compact('users'), array('users' => $users));

}
public function getLogin() {
return View::make('users.login');
$this->layout->content = View::make('users.login');
}

I have created two view files under the "app\views\users" location:

  1. user.blade.php (master blade file)
  2. login.blade.php (

The content of user.blade file is below:

<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>@yield('title')</title>
    <meta name="description" content="@yield('description')">
    <link href="//netdna.bootstrapcdn.com/twitter-bootstrap
    /2.3.1/css/bootstrap-combined.min.css" rel="stylesheet">
    <style>
        table form { margin-bottom: 0; }
        form ul { margin-left: 0; list-style: none; }
        .error { color: red; font-style: italic; }
        body { padding-top: 20px; }
        /* Pagination styling */ 

        .pagination { display: inline-block; padding-right: 0; margin: 20px 0; border-radius: 4px; float: right; } .pagination>li { display: inline } .pagination>li>a, .pagination>li>span { position: relative; float: right; padding: 6px 12px; line-height: 1.428571429; text-decoration: none; color: #333333; background-color: #fff; border: 1px solid #e4e4e4; } .pagination>li:first-child>a, .pagination>li:first-child>span { margin-right: 0; border-bottom-right-radius: 4px; border-top-right-radius: 4px } .pagination>li:last-child>a, .pagination>li:last-child>span { border-bottom-left-radius: 4px; border-top-left-radius: 4px } .pagination>li>a:hover, .pagination>li>span:hover, .pagination>li>a:focus, .pagination>li>span:focus { color: #fff; background-color: #ffae12; border-color: #ffae12 } .pagination>.active>a, .pagination>.active>span, 
        .pagination>.active>a:hover, .pagination>.active>span:hover, .pagination>.active>a:focus, .pagination>.active>span:focus { z-index: 2; color: #fff; background-color: #F2541B; border-color: #F2541B; cursor: default } .pagination>.disabled>span, .pagination>.disabled>span:hover, .pagination>.disabled>span:focus, .pagination>.disabled>a, .pagination>.disabled>a:hover, .pagination>.disabled>a:focus { color: #777; background-color: #fff; border-color: #ddd; cursor: not-allowed } .pagination-lg>li>a, .pagination-lg>li>span { padding: 10px 16px; font-size: 18px } .pagination-lg>li:first-child>a, .pagination-lg>li:first-child>span { border-bottom-right-radius: 6px; border-top-right-radius: 6px } .pagination-lg>li:last-child>a, .pagination-lg>li:last-child>span { border-bottom-left-radius: 6px; border-top-left-radius: 6px } .pagination-sm>li>a, .pagination-sm>li>span { 
        padding: 5px 10px; font-size: 12px } 
        .pagination-sm>li:first-child>a, .pagination-sm>li:first-child>span { border-bottom-right-radius: 3px; border-top-rightt-radius: 3px } .pagination-sm>li:last-child>a, .pagination-sm>li:last-child>span { border-bottom-left-radius: 3px; border-top-left-radius: 3px }



    </style>
</head>

<body>

    <div class="container">
        @if (Session::has('message'))
            <div class="flash alert">
                <p>{{ Session::get('message') }}</p>
            </div>
        @endif

        @yield('main')
    </div>

</body>

The content for login.blade file is below:

@extends('users.user') 

@section('main')

<h1>Login</h1>

{{ Form::open(array('route' => 'users.getlogin')) }}
<ul>


    <li>
        {{ Form::label('username', 'Username:') }}
        {{ Form::text('username') }}
    </li>

    <li>
        {{ Form::label('password', 'Password:') }}
        {{ Form::password('password') }}
    </li>


    <li>
        {{ Form::submit('Submit', array('class' => 'btn')) }}
    </li>
</ul>
{{ Form::close() }}

@if ($errors->any())
<ul>
    {{ implode('', $errors->all('<li class="error">:message</li>')) }}
</ul>
@endif

@stop



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire