be-codified
be-codified

Reputation: 6144

Laravel 5 - cant get records

I can not get any records by using

return Offer::all();

although I see them if using

return DB::select('select * from offers where id = ?', array(1));

I get following error:

FatalErrorException in OffersController.php line 21:
Class 'App\Http\Controllers\Offer' not found

Both commands were run from OffersController. I also have model file

<?php namespace App;
use Illuminate\Database\Eloquent\Model;
class Offer extends Model {

protected $fillable = array('title', 'done');
}

What am I doing wrong? I think I will use both 'DB' and 'Eloquent' in the future.

Upvotes: 0

Views: 41

Answers (1)

retrograde
retrograde

Reputation: 2979

Add the following at the top of your OffersController

use Offer;

or perhaps

use App\Offer;

Upvotes: 3

Related Questions