调用未定义的方法Illuminate \ Database \ Query \ Builder :: getForeignKey()

时间:2017-01-26 09:38:19

标签: php laravel datatables

我正在使用datatables服务器端并刚刚升级到Laravel 5.4并且我得到了上述错误......它似乎与急切加载有关......

[2017-01-26 09:32:16] local.ERROR: BadMethodCallException: Call to undefined method Illuminate\Database\Query\Builder::getForeignKey() in /var/www/html/odie/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:2508
Stack trace:

    0 /var/www/html/odie/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(1322): Illuminate\Database\Query\Builder->__call('getForeignKey', Array)

    1 [internal function]: Illuminate\Database\Eloquent\Builder->__call('getForeignKey', Array)

    2 /var/www/html/odie/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/Relation.php(331): call_user_func_array(Array, Array)

    3 /var/www/html/odie/vendor/yajra/laravel-datatables-oracle/src/Engines/QueryBuilderEngine.php(544): Illuminate\Database\Eloquent\Relations\Relation->__call('getForeignKey', Array)

    4 /var/www/html/odie/vendor/yajra/laravel-datatables-oracle/src/Engines/QueryBuilderEngine.php(639): Yajra\Datatables\Engines\QueryBuilderEngine->joinEagerLoadedColumn('visi_patn', 'name')

    5 /var/www/html/odie/vendor/yajra/laravel-datatables-oracle/src/Engines/BaseEngine.php(611): Yajra\Datatables\Engines\QueryBuilderEngine->ordering()

    6 /var/www/html/odie/vendor/yajra/laravel-datatables-oracle/src/Engines/BaseEngine.php(595): Yajra\Datatables\Engines\BaseEngine->orderRecords(false)

    7 /var/www/html/odie/vendor/yajra/laravel-datatables-oracle/src/Engines/QueryBuilderEngine.php(77): Yajra\Datatables\Engines\BaseEngine->make(true, false)

1 个答案:

答案 0 :(得分:1)

仅通过查看堆栈跟踪而不查看实现,很难完全回答您的问题。

但从它的外观来看,你在getForeignKey()上调用了builder方法,但实际上你应该做的是

Model::getForeignKey()