42 lines
1.1 KiB
PHP
42 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Concerns\HasUuids;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
class Label extends Model
|
|
{
|
|
/** @use HasFactory<\Database\Factories\LabelFactory> */
|
|
use HasFactory, HasUuids, SoftDeletes;
|
|
|
|
protected $fillable = [
|
|
'name',
|
|
'color',
|
|
'user_id',
|
|
];
|
|
|
|
/** @return BelongsTo<User, $this> */
|
|
public function user(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class);
|
|
}
|
|
|
|
public function transactions(): BelongsToMany
|
|
{
|
|
return $this->belongsToMany(Transaction::class)
|
|
->using(LabelTransaction::class)
|
|
->withTimestamps();
|
|
}
|
|
|
|
public function automationRules(): BelongsToMany
|
|
{
|
|
return $this->belongsToMany(AutomationRule::class, 'automation_rule_labels')
|
|
->using(AutomationRuleLabel::class);
|
|
}
|
|
}
|