|
@@ -8,13 +8,23 @@ use Illuminate\Database\Eloquent\Model;
|
|
|
class Tag extends Model
|
|
class Tag extends Model
|
|
|
{
|
|
{
|
|
|
|
|
|
|
|
|
|
+ protected $primaryKey = 'id';
|
|
|
protected $keyType = 'string';
|
|
protected $keyType = 'string';
|
|
|
- protected $fillable = ['name' , 'owner_id'];
|
|
|
|
|
|
|
+ protected $casts = [
|
|
|
|
|
+ 'id' => 'string'
|
|
|
|
|
+ ];
|
|
|
|
|
+ protected $fillable = ['name', 'owner_id'];
|
|
|
|
|
|
|
|
use HasFactory;
|
|
use HasFactory;
|
|
|
|
|
|
|
|
public function chapters()
|
|
public function chapters()
|
|
|
{
|
|
{
|
|
|
- return $this->belongsToMany('App\Models\ProgressChapter','tag_maps','tag_id','anchor_id');
|
|
|
|
|
|
|
+ return $this->belongsToMany('App\Models\ProgressChapter', 'tag_maps', 'tag_id', 'anchor_id');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 定义与 TagMap 模型的一对多关系
|
|
|
|
|
+ public function tag_maps()
|
|
|
|
|
+ {
|
|
|
|
|
+ return $this->hasMany(TagMap::class);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|