Try this route:
Route::get('users', 'UsersController@index');
And in controller just try echoing something
to see if you are making it that far. comment out
everything in index and maybe:
echo 'made it here';
and move echo to various spots til you find the problem.
You said you had debug to true already, may even be a problem in htaccess.
Also just try changing:
class UsersController extends \BaseController {
to
class UsersController extends Controller {
Could it be that you are missing
@extends('user')
at the top of your users.main file?
abhiyanp said:
Could it be that you are missing
@extends('user')
at the top of your users.main file?
there is no users.main? hmmm >jimgwhit said:
Try this route:
Route::get('users', 'UsersController@index');
And in controller just try echoing something
to see if you are making it that far. comment out
everything in index and maybe:echo 'made it here';
and move echo to various spots til you find the problem.
You said you had debug to true already, may even be a problem in htaccess.Also just try changing:
class UsersController extends \BaseController {
to
class UsersController extends Controller {
It is making it to the index() function, thanks for your echo suggestion.
When i changed to this:
class UsersController extends Controller {
I got an error
Route [users.create] not defined.
This is the htaccess:
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
it does seem that inside index.blade.php, the following code throws a spanner in the works:
@section('main')
I can echo things before it, but not after it.
@cardi777 I meant to say users.index.blade file (users.index) sorry..
If this doesn't work try sending just a single data item to view just to see if anything will pass.
Also if you have another function for create you will have to make another route for that like:
public function create()
{
//your create code
}
and
Route::post('create', 'UsersController@create');
Usually an edit or create will be a post.
A route is needed for each seperate function in a controller.
One more trick is try this. In your contriller where:
$users = User::all();
right agter this put:
print_r($users);
Do this with the view::make commented out. This will show if the data is being retrieved
from the database. If not perhaps something in wrong with model, good luck.
jimgwhit said:
@cardi777 I meant to say users.index.blade file (users.index) sorry..
If this doesn't work try sending just a single data item to view just to see if anything will pass.
Also if you have another function for create you will have to make another route for that like:public function create() { //your create code }
and
Route::post('create', 'UsersController@create');
Usually an edit or create will be a post.
A route is needed for each seperate function in a controller.One more trick is try this. In your contriller where:
$users = User::all();
right agter this put:
print_r($users);
Do this with the view::make commented out. This will show if the data is being retrieved
from the database. If not perhaps something in wrong with model, good luck.
your idea worked, and the DB entries are pumping out.
I got the page but its blank.
In index.blade.php, i did this:
<? echo 1; ?>
@section('main')
<? echo 2; ?>
<h1>All Users</h1>
I don't get the "2", i only get the "1".
Something fails at this point
@section('main')
It has become apparent to me that my views/layouts/users.blade.php isn't being recognised - i can remove all the content and it gives me nothing :P
This is my users model file (models/User.php)
<?php
use Illuminate\Auth\UserTrait;
use Illuminate\Auth\UserInterface;
use Illuminate\Auth\Reminders\RemindableTrait;
use Illuminate\Auth\Reminders\RemindableInterface;
class User extends Eloquent implements UserInterface, RemindableInterface {
use UserTrait, RemindableTrait;
/**
* The database table used by the model.
*
* @var string
*/
protected $table = 'users';
/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/
protected $hidden = array('password', 'remember_token');
}
can't help but wonder if this has something to do with user / users being used the wrong way somewhere.
i needed to add
@extends('layouts.users')
but not
@extends('user')
I had this same problem. In your last post you say you had to add:
@extends('layouts.users')
I think you meant layouts.user (non-plural), this is what the book specifies the name should be anyway and this is what worked for me.
And just to clarify for anyone else with this problem, this code is to be added at the first line of the file: app/views/users/index.blade.php
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community