Laravel Administrator包关系错误

时间:2014-11-11 17:38:45

标签: php laravel eloquent ardent

我的Ardent模型有像这样的has_one关系

public static $relationsData = array(
'organization'  => array(self::HAS_ONE, 'Organization', 'foreignKey' => 'party_id'),
);

现在,我的Laravel Administrator软件包的模型配置文件具有这样的列配置

'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

* 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);

1 个答案:

答案 0 :(得分:0)

(我回答了这个问题here,现在我只是在唠叨声誉!)

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

//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 '.'");
}