getKey(); } /** * Whether $actor is allowed to see the goal (including its progress). */ public function canViewGoal(Member $actor, Goal $goal): bool { return $goal->isPersonalGoalOf($actor); } /** * Whether $actor is allowed to update the goal (including its filters and archiving it). */ public function canUpdateGoal(Member $actor, Goal $goal): bool { return $goal->isPersonalGoalOf($actor); } /** * Whether $actor is allowed to delete the goal. */ public function canDeleteGoal(Member $actor, Goal $goal): bool { return $goal->isPersonalGoalOf($actor); } /** * Restrict the query to the goals that $actor is allowed to see. * * @param Builder $query * @return Builder */ public function scopeVisibleGoals(Builder $query, Member $actor): Builder { return $query->where('type', '=', GoalType::Personal->value) ->where('member_id', '=', $actor->getKey()); } }