spatie / laravel-comments-app

An application for testing out laravel-comments
https://laravel-comments.com
5 stars 2 forks source link

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'comments.video_id' in 'where clause' #5

Closed kylemabaso closed 1 year ago

kylemabaso commented 1 year ago

Hi.

I just setup a new app with a video model. I get this error after installing comments (select count(*) as aggregate from comments where comments.video_id = 1 and comments.video_id is not null).

Below is my code:


                <livewire:comments :model="$video" no-comments-text="What are your thoughts on this?" newest-first/>
                @endauth

                @guest
                    <livewire:comments read-only :model="$video"/>

                    <p class="comments-no-comment-yet">
                        Log in to make a comment...
                    </p>
                @endguest```

```<?php

namespace App\Models;

use Cviebrock\EloquentSluggable\Sluggable;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Overtrue\LaravelLike\Traits\Likeable;
use Spatie\Comments\Models\Concerns\HasComments;

class Video extends Model
{
    use HasFactory, HasComments, Sluggable, Likeable;

    protected $fillable = [
        'channel_id',
        'video_category_id',
        'title',
        'slug',
        'description',
        'video',
        'thumbnail',
        'is_public',
        'is_approved'
    ];

    /**
     * Return the sluggable configuration array for this model.
     *
     * @return array
     */

    public function sluggable(): array
    {
        return [
            'slug' => [
                'source' => 'title'
            ]
        ];
    }

    /*
 * This string will be used in notifications on what a new comment
 * was made.
 */
    public function commentableName(): string
    {
        //
    }

    /*
     * This URL will be used in notifications to let the user know
     * where the comment itself can be read.
     */
    public function commentUrl(): string
    {

    }```
kylemabaso commented 1 year ago

I had a comments relationship in the Video model.