Search code examples
phplaravelforeign-keyslaravel-5

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?


Solution

  • i create again my thread on database without s and its solve