Laravel 4.1 Eloquent ORM custom table name

Viewed 1561

I am creating api with Laravel. I have a table name "rfp_requests" and my ORM model name is Request. I saw in Laravel documentation in order to use custom table name I have to specify the table name that I did. But still it's not working. Here is my model code:

class Request extends Eloquent {
    /**
     * Database table used by model
     * @var string
     */

    protected   $table = 'rfp_requests';

}

Here is my controller code. I also tried to see the executed query. But it doesn't show anything.

class RequestController extends BaseController {

    /**
     * Display a listing of the resource.
     *
     * @return Response
     */
    public function index()
    {
        $requestData = Request::all();
        $queries = DB::getQueryLog();
        Log::info($queries);
        return $requestData;
    }
}

Here is my route code:

Route::resource('requests', 'RequestController');
Route::model('requests', 'Request');

When I hit The url I see empty array.I am not sure what I am doing wrong. Can someone show me what is the correct way to specify custom table name in Laravel Eloquent ORM.

1 Answers
Related