php - Syntax error when using simple query to database table -


i have simple setup in laravel while i'm learning , can't figure why i'm getting error. it's simple overlooking.

i can this:

route::get('users', function() {     $users = user::all();     return view::make('users')->with('users', $users); }); 

example on laravel work perfectly, displaying information in users.blade.php view.

in database have 'lists' table when copy structure of code above try , display lists receive following error.

syntax error, unexpected '::' (t_paamayim_nekudotayim), expecting '(' 

on line

 $lists = list::all(); 

my code follows routes.php

route::get('lists', function() {     $lists = list::all();     return view::make('lists')->with('lists', $lists); }); 

list.php /models

<?php class list extends eloquent {} 

lists.blade.php /views

@extends('layouts.main') @section('content') @foreach($lists $list)     <p>{{ $list->name }}</p> @endforeach @stop 

any appreciated. thanks.

list reserved keyword in php, may not use class name. documentation:

these words have special meaning in php. of them represent things functions, constants, , on - they're not, really: language constructs. cannot use of following words constants, class names, function or method names.

unfortunately, you're going need have different class name, set object's table name 'lists' such:

class applist extends eloquent { protected $table = 'lists'; } 

Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -