问题
I am using Laravel 5.8 with PHP 7.1 It gives the warning with the references() function.
$table->foreign('student_id')->references('student_id')->on('student');
The error is:
Warning:(52, 45) Method 'references' not found in Illuminate\Support\Fluent
Thanks in advance.
回答1:
It's your IDE complaining not a laravel issue. Add this code to the top of your _ide_helper.php
file.
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 {}
}
Your issue should be fixed after this
来源:https://stackoverflow.com/questions/55223603/method-references-not-found-in-illuminate-support-fluent-in-laravel-5-8