duality_
duality_

Reputation: 18756

Laravel 4: Eloquent::find() doesn't work

So I have a simple, empty Eloquent class: class Worker extends Eloquent {}. Then in the controller I write: Worker::find(1); and I get an exception, saying that the SQL is incorrect:

select * where `id` = ?

Obviously, the from SQL clause is missing.

Oh, I downloaded the Laravel 4 for this app today.

Upvotes: 0

Views: 3225

Answers (2)

danharper
danharper

Reputation: 766

As already mentioned, you have to specifically set a $table property on the model. Taylor has mentioned here that the old way of doing things (a default table name as the plural of the model's name) may be returning. There just isn't a good composer package for pluralising, so the L3 code may be ported.

Upvotes: 2

Cody Covey
Cody Covey

Reputation: 1060

In Laravel 4 you have to set a table property

protected $table = 'foo';

Upvotes: 3

Related Questions