*/ public $guarded = []; /** @var array */ public $casts = [ 'from' => 'date', 'to' => 'date', 'promised_at' => 'date', ]; /** * @return BelongsTo */ public function activity(): BelongsTo { return $this->belongsTo(Activity::class); } /** * @return BelongsTo */ public function subactivity(): BelongsTo { return $this->belongsTo(Subactivity::class); } /** * @param Builder $query * * @return Builder */ public function scopeActive(Builder $query): Builder { return $query->whereNull('to'); } /** * @param Builder $query * * @return Builder */ public function scopeIsAgeGroup(Builder $query): Builder { return $query->whereHas('subactivity', fn ($builder) => $builder->where('is_age_group', true)); } /** * @param Builder $query * * @return Builder */ public function scopeIsMember(Builder $query): Builder { return $query->whereHas('activity', fn ($builder) => $builder->where('is_member', true)); } /** * @param Builder $query * * @return Builder */ public function scopeIsLeader(Builder $query): Builder { return $query->whereHas('activity', fn ($builder) => $builder->where('has_efz', true)); } /** * @param Builder $query * * @return Builder */ public function scopeTrying(Builder $query): Builder { return $query->whereHas('activity', fn ($builder) => $builder->where('is_try', true)); } }