|
@@ -10,13 +10,27 @@ class Sentence extends Model
|
|
|
{
|
|
{
|
|
|
use HasFactory;
|
|
use HasFactory;
|
|
|
use SoftDeletes;
|
|
use SoftDeletes;
|
|
|
- protected $fillable = ['id','uid','book_id',
|
|
|
|
|
- 'paragraph','word_start','word_end',
|
|
|
|
|
- 'channel_uid','editor_uid','content','content_type',
|
|
|
|
|
- 'strlen','status','create_time','modify_time','language'];
|
|
|
|
|
|
|
+ protected $fillable = [
|
|
|
|
|
+ 'id',
|
|
|
|
|
+ 'uid',
|
|
|
|
|
+ 'book_id',
|
|
|
|
|
+ 'paragraph',
|
|
|
|
|
+ 'word_start',
|
|
|
|
|
+ 'word_end',
|
|
|
|
|
+ 'channel_uid',
|
|
|
|
|
+ 'editor_uid',
|
|
|
|
|
+ 'content',
|
|
|
|
|
+ 'content_type',
|
|
|
|
|
+ 'strlen',
|
|
|
|
|
+ 'status',
|
|
|
|
|
+ 'create_time',
|
|
|
|
|
+ 'modify_time',
|
|
|
|
|
+ 'language'
|
|
|
|
|
+ ];
|
|
|
protected $primaryKey = 'uid';
|
|
protected $primaryKey = 'uid';
|
|
|
protected $casts = [
|
|
protected $casts = [
|
|
|
- 'uid' => 'string'
|
|
|
|
|
|
|
+ 'uid' => 'string',
|
|
|
|
|
+ 'channel_uid' => 'string',
|
|
|
];
|
|
];
|
|
|
|
|
|
|
|
protected $dates = [
|
|
protected $dates = [
|
|
@@ -26,4 +40,25 @@ class Sentence extends Model
|
|
|
'fork_at'
|
|
'fork_at'
|
|
|
];
|
|
];
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 获取句子所属的频道
|
|
|
|
|
+ */
|
|
|
|
|
+ public function channel()
|
|
|
|
|
+ {
|
|
|
|
|
+ return $this->belongsTo(Channel::class, 'channel_uid', 'uid');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public function scopeNissaya($query)
|
|
|
|
|
+ {
|
|
|
|
|
+ return $query->whereHas('channel', function ($q) {
|
|
|
|
|
+ $q->where('type', 'nissaya');
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public function scopeLanguage($query, $language)
|
|
|
|
|
+ {
|
|
|
|
|
+ return $query->whereHas('channel', function ($q) use ($language) {
|
|
|
|
|
+ $q->where('lang', $language);
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|