首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Laravel Administrator包关系错误

Laravel Administrator包关系错误
EN

Stack Overflow用户
提问于 2014-11-12 01:38:45
回答 1查看 217关注 0票数 0

我的Ardent模型有一个这样的has_one关系

代码语言:javascript
复制
public static $relationsData = array(
'organization'  => array(self::HAS_ONE, 'Organization', 'foreignKey' => 'party_id'),
);

现在,我的Laravel Administrator包的模型配置文件有如下列配置

代码语言:javascript
复制
'columns' => array(
'id',
'organization' => array(
    'title' => "Organization",
    'relationship' => 'organization', //this is the name of the Eloquent relationship method!
    'select' => "(:table).organization_name",
),
'address' 
),

现在,它抛出一个错误,如下所示

已达到'100‘的最大函数嵌套级别,正在中止!打开: C:\xampp\htdocs\hrms\vendor\laravel\framework\src\Illuminate\Support\Str.php

代码语言:javascript
复制
* Convert a value to studly caps case.
*
* @param  string  $value
* @return string
*/
public static function studly($value)
{
    $value = ucwords(str_replace(array('-', '_'), ' ', $value));

return str_replace(' ', '', $value);
EN

回答 1

Stack Overflow用户

发布于 2014-11-15 10:08:51

(我回答了这个here,现在我只是为了名声!)

使用@bobiasg在issue #418中给出的解决方案,我能够解决这个错误。这是用Administrator/DataTable/Columns/Relationships/BelongsTo.php:71编写的

代码语言:javascript
复制
//if the model method doesn't exist for any of the pieces along the way, exit out
if ((!method_exists($models[$i], $rel) && !is_callable(array($models[$i], $rel))) || !is_a($models[$i]->{$rel}(), self::BELONGS_TO))
{
    throw new \InvalidArgumentException("The '" . $this->getOption('column_name') . "' column in your " . $this->config->getOption('name') .
        " model configuration needs to be either a belongsTo relationship method name or a sequence of them connected with a '.'");
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26870995

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档