Files
ahrommag/app/Models/CommonWordBlog.php
2025-11-16 12:43:07 +03:30

50 lines
938 B
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Relations\Pivot;
class CommonWordBlog extends Pivot
{
protected $table = 'common_word_blog';
protected $fillable = [
'common_word_id',
'blog_id',
'count',
'is_linked',
];
public $timestamps = true;
protected $casts = [
'count' => 'integer',
'is_linked' => 'boolean',
];
public function commonWord()
{
return $this->belongsTo(CommonWord::class);
}
public function blog()
{
return $this->belongsTo(Blog::class);
}
public function scopeLinked($query)
{
return $query->where('is_linked', true);
}
public function scopeNotLinked($query)
{
return $query->where('is_linked', false);
}
public function scopeWithHighFrequency($query, $minCount = 5)
{
return $query->where('count', '>=', $minCount);
}
}