Support the ongoing development of Laravel.io →
Database Eloquent

To answer http://forumsarchive.laravel.io/viewtopic.php?id=11485

$test = new Test();
$test->setTable('fields');
$data = $test->getQuery()->find(1);

You need the getQuery function before the find for to get past the "Base table or view not found: 1146 Table 'test.tests' doesn't exist" error.

Unfortunately findOrFail doesn't work this way.

Last updated 3 years ago.
0

Sign in to participate in this thread!

PHPverse

Your banner here too?

malhal malhal Joined 2 Sep 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.