*/ use HasFactory, HasUuids; protected $fillable = [ 'transaction_id', 'category_id', 'amount', ]; /** * Hide the pivot so a Label loaded through this line's labels() looks * identical to one loaded elsewhere. * * @var list */ protected $hidden = [ 'pivot', ]; protected function casts(): array { return [ 'amount' => 'integer', ]; } /** @return BelongsTo */ public function transaction(): BelongsTo { return $this->belongsTo(Transaction::class); } /** @return BelongsTo */ public function category(): BelongsTo { return $this->belongsTo(Category::class); } /** @return BelongsToMany */ public function labels(): BelongsToMany { return $this->belongsToMany(Label::class, 'label_split') ->using(LabelSplit::class) ->withTimestamps(); } }