پاسخ به موضوع

1 هفته پیش amir این پرسش را مطرح کرد 5 نفر پاسخ داده اند

سوال در مبحث نمایش نظرات

سلام و خسته نباشید ، وقتی زیر هر پستی نظری ثبت میکنم درون دیتابیس آیدی هر پست و کاربر رو ثبت میکنه ولی وارد هر سینگل پست بشی همه نظرات نمایش داده میشه، حتی اگه زیر پستی نظری ندادم بازم همه ی نظرها دیده میشه.

ابوالفضل احمدی

abolfazlahmadi@

اگه با این اصول نمایش بدید هیچ مشکلی نباید باشه

SELECT * FROM comments WHERE status = 1 AND product_id = 1;

اگه با این اصول نمایش بدید هیچ مشکلی نباید باشه

SELECT * FROM comments WHERE status = 1 AND product_id = 1;

amir

amirz@

@abolfazlahmadi والله همه چی طبق آموزش میره جلو ولی نمیدونم چی شده که این خطا پیش میاد

amir

amirz@

@amirz ```php public function up(): void { Schema::create('socialcomments', function (Blueprint $table) { $table->id(); $table->integer('user_id'); $table->integer('social_id'); $table->text('content'); $table->integer('child')->nullable(); $table->integer('status')->default(0); $table->timestamps(); }); }

###### مدل محصول 

```php
class Social extends Model
{
    use HasFactory;
    protected $fillable=['title','image','description','category_id'];

    public function comments()
    {
      return $this->hasMany(Socialcomment::class);
    }
 }

مدل کامنت مربوط به قسمت social
class Socialcomment extends Model
{
    use HasFactory;

    protected $fillable=['user_id','social_id','content','child','status'];

    public function user()
    {
        return $this->belongsTo(user::class);
    }

    public function social()
    {
        return $this->belongsTo(Social::class);
    }
 }

اینم به اصطلاح صفحه سینگل پست که نظرها رو زیرش نشون میدم
@foreach ($social->comments as $comment )
<div class="container-fluid pb-4 pt-5" >
    <div class="container animate-box">
        <h1>{{$comment->user->name}}</h1> 
        <h2>{{$comment->content }}</h2> 
    </div>
</div>
@endforeach

amir

amirz@

@amirz ```php public function up(): void { Schema::create('socialcomments', function (Blueprint $table) { $table->id(); $table->integer('user_id'); $table->integer('social_id'); $table->text('content'); $table->integer('child')->nullable(); $table->integer('status')->default(0); $table->timestamps(); }); }

###### مدل محصول 

```php
class Social extends Model
{
    use HasFactory;
    protected $fillable=['title','image','description','category_id'];

    public function comments()
    {
      return $this->hasMany(Socialcomment::class);
    }
 }

مدل کامنت مربوط به قسمت social
class Socialcomment extends Model
{
    use HasFactory;

    protected $fillable=['user_id','social_id','content','child','status'];

    public function user()
    {
        return $this->belongsTo(user::class);
    }

    public function social()
    {
        return $this->belongsTo(Social::class);
    }
 }

اینم به اصطلاح صفحه سینگل پست که نظرها رو زیرش نشون میدم
@foreach ($social->comments as $comment )
<div class="container-fluid pb-4 pt-5" >
    <div class="container animate-box">
        <h1>{{$comment->user->name}}</h1> 
        <h2>{{$comment->content }}</h2> 
    </div>
</div>
@endforeach

amir

amirz@

@amirz ```php public function up(): void { Schema::create('socialcomments', function (Blueprint $table) { $table->id(); $table->integer('user_id'); $table->integer('social_id'); $table->text('content'); $table->integer('child')->nullable(); $table->integer('status')->default(0); $table->timestamps(); }); }

###### مدل محصول 

```php
class Social extends Model
{
    use HasFactory;
    protected $fillable=['title','image','description','category_id'];

    public function comments()
    {
      return $this->hasMany(Socialcomment::class);
    }
 }

مدل کامنت مربوط به قسمت social
class Socialcomment extends Model
{
    use HasFactory;

    protected $fillable=['user_id','social_id','content','child','status'];

    public function user()
    {
        return $this->belongsTo(user::class);
    }

    public function social()
    {
        return $this->belongsTo(Social::class);
    }
 }

اینم به اصطلاح صفحه سینگل پست که نظرها رو زیرش نشون میدم
@foreach ($social->comments as $comment )
<div class="container-fluid pb-4 pt-5" >
    <div class="container animate-box">
        <h1>{{$comment->user->name}}</h1> 
        <h2>{{$comment->content }}</h2> 
    </div>
</div>
@endforeach