Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/performance/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Laravel 5 Laravel雄辩的关系FatalErrorException在compiled.php行9573中:找不到课堂讲课_Laravel 5 - Fatal编程技术网

Laravel 5 Laravel雄辩的关系FatalErrorException在compiled.php行9573中:找不到课堂讲课

Laravel 5 Laravel雄辩的关系FatalErrorException在compiled.php行9573中:找不到课堂讲课,laravel-5,Laravel 5,我试图在项目和讲座之间建立一对多的关系,讲座有很多项目 这是我的讲座迁移表: Schema::create('lectures', function(Blueprint $table) { $table->increments('id'); $table->string('title', 255); $table->integer('lecturer'); });

我试图在项目和讲座之间建立一对多的关系,讲座有很多项目

这是我的
讲座
迁移表:

        Schema::create('lectures', function(Blueprint $table) {
            $table->increments('id');
            $table->string('title', 255);
            $table->integer('lecturer');
        });
        Schema::create('items', function(Blueprint $table) {
            $table->increments('id');
            $table->string('name', 255);
            $table->integer('lecture_id');

            $table->foreign('lecture_id')->references('id')
                ->on('lectures');
        });
这是我的
项目
迁移表:

        Schema::create('lectures', function(Blueprint $table) {
            $table->increments('id');
            $table->string('title', 255);
            $table->integer('lecturer');
        });
        Schema::create('items', function(Blueprint $table) {
            $table->increments('id');
            $table->string('name', 255);
            $table->integer('lecture_id');

            $table->foreign('lecture_id')->references('id')
                ->on('lectures');
        });
最后,以下是我如何将它们连接在一起:

class Item extends Model
{
    public function lecture()
    {
        return $this->belongsTo('Lecture', 'lecture_id', 'id');
    }
}


我想知道出了什么问题,为什么我总是出错。我尝试了
composer dump autoload
php-artisan-migrate:refresh
,以及
php-artisan-db:seed
。但在Laravel 5中,它不起作用,在使用其他类时,需要在代码中添加“use”行

如果你的课堂模型课就在应用程序目录下,你需要添加

use App\Lecture;

您的PHP代码/类需要它。

谢谢,虽然这并不完全正确,但我发现错误是因为我没有使用完整路径。我应该写
return$this->belongsTo('App\Models\AMS1B\touch','touch\u id','id')而不仅仅是
讲座