ابوالفضل احمدی
abolfazlahmadi@
اگه با این اصول نمایش بدید هیچ مشکلی نباید باشه
SELECT * FROM comments WHERE status = 1 AND product_id = 1;
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);
}
}
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);
}
}
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);
}
}
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
سوال در مبحث نمایش نظرات
سلام و خسته نباشید ، وقتی زیر هر پستی نظری ثبت میکنم درون دیتابیس آیدی هر پست و کاربر رو ثبت میکنه ولی وارد هر سینگل پست بشی همه نظرات نمایش داده میشه، حتی اگه زیر پستی نظری ندادم بازم همه ی نظرها دیده میشه.