47 lines
1.2 KiB
PHP
47 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
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\Relations\HasMany;
|
|
|
|
class Decision extends Model
|
|
{
|
|
/** @use HasFactory<\Database\Factories\DecisionFactory> */
|
|
use HasFactory;
|
|
|
|
protected $fillable = ['name', 'color_tag', 'auto_mail', 'email_template_id'];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'auto_mail' => 'boolean',
|
|
];
|
|
}
|
|
|
|
public function actions(): BelongsToMany
|
|
{
|
|
return $this->belongsToMany(\App\Models\Action::class);
|
|
}
|
|
|
|
public function events(): BelongsToMany
|
|
{
|
|
return $this->belongsToMany(\App\Models\Event::class)
|
|
->withPivot(['run_order', 'active', 'config'])
|
|
->withTimestamps();
|
|
}
|
|
|
|
public function activities(): HasMany
|
|
{
|
|
return $this->hasMany(\App\Models\Activity::class);
|
|
}
|
|
|
|
public function emailTemplate(): BelongsTo
|
|
{
|
|
return $this->belongsTo(\App\Models\EmailTemplate::class, 'email_template_id');
|
|
}
|
|
}
|