. */ declare(strict_types=1); namespace FireflyIII\Models; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\SoftDeletes; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; /** * Class Rule. */ class Rule extends Model { use SoftDeletes; /** * The attributes that should be casted to native types. * * @var array */ protected $casts = [ 'created_at' => 'datetime', 'updated_at' => 'datetime', 'deleted_at' => 'datetime', 'active' => 'boolean', 'order' => 'int', 'stop_processing' => 'boolean', ]; /** * @param string $value * * @return Rule */ public static function routeBinder(string $value): Rule { if (auth()->check()) { $ruleId = intval($value); $rule = auth()->user()->rules()->find($ruleId); if (!is_null($rule)) { return $rule; } } throw new NotFoundHttpException; } /** * @codeCoverageIgnore * @return \Illuminate\Database\Eloquent\Relations\HasMany */ public function ruleActions() { return $this->hasMany('FireflyIII\Models\RuleAction'); } /** * @codeCoverageIgnore * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function ruleGroup() { return $this->belongsTo('FireflyIII\Models\RuleGroup'); } /** * @codeCoverageIgnore * @return \Illuminate\Database\Eloquent\Relations\HasMany */ public function ruleTriggers() { return $this->hasMany('FireflyIII\Models\RuleTrigger'); } /** * @codeCoverageIgnore * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function user() { return $this->belongsTo('FireflyIII\User'); } }