简体   繁体   中英

Error column not found in Laravel

This is my forumthread table:

        $table->increments('id');
        $table->integer('user_id')->unsigned();
        $table->foreign( 'user_id' )->references( 'id' )->on( 'users' );
        $table->string('thread');
        $table->string('slug');
        $table->dateTime('published_at');

And this is my forumindex table:

        $table->increments('id');
        $table->integer('user_id')->unsigned();
        $table->foreign( 'user_id' )->references( 'id' )->on( 'users' );
        $table->integer('forumthreads_id')->unsigned();
        $table->foreign( 'forumthreads_id' )->references( 'id' )->on( 'forumthreads' );
        $table->string('slug');
        $table->string('title');
        $table->text('body');
        $table->dateTime('published_at');

In my forumthread table I have a hasmany('forumindex'); and in my forumindex a belongsTo('forumthread'); . When I render the view it says column not found .

Here's the view:

@foreach($thread->forumindex()->orderBy('created_at', 'desc')->paginate(9) as $forumindex)
    <p>{{ $forumindex->title }}</p>
@endforeach

What is it that I am missing?

我在没有 s 的数据库上再次创建我的线程及其解决方案

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM