在Laravel 5.8的Illuminate \ Support \ Fluent中找不到方法“引用”

时间:2019-03-18 14:25:09

标签: laravel eloquent

我正在将Laravel 5.8与PHP 7.1一起使用 它使用references()函数给出警告。

$table->foreign('student_id')->references('student_id')->on('student');

错误是:

Warning:(52, 45) Method 'references' not found in Illuminate\Support\Fluent

谢谢。

1 个答案:

答案 0 :(得分:2)

这是您的IDE抱怨的不是Laravel问题。将此代码添加到您的_ide_helper.php文件的顶部。

namespace Illuminate\Support{
/**
 * @method Fluent first()
 * @method Fluent after($column)
 * @method Fluent change()
 * @method Fluent nullable()
 * @method Fluent unsigned()
 * @method Fluent unique()
 * @method Fluent index()
 * @method Fluent primary()
 * @method Fluent default($value)
 * @method Fluent onUpdate($value)
 * @method Fluent onDelete($value)
 * @method Fluent references($value)
 * @method Fluent on($value)
 */
class Fluent {}
}

此后,您的问题应该得到解决