Skip to content

Commit

Permalink
Update missed references.
Browse files Browse the repository at this point in the history
  • Loading branch information
dgoetzit committed Mar 5, 2024
1 parent 8c751e2 commit 68841ba
Show file tree
Hide file tree
Showing 41 changed files with 183 additions and 287 deletions.
185 changes: 90 additions & 95 deletions app-modules/alert/graphql/alert.graphql
Original file line number Diff line number Diff line change
@@ -1,132 +1,127 @@
type Alert @model(class: "AdvisingApp\\Alert\\Models\\Alert") {
"Unique primary key."
id: UUID!
"Unique primary key."
id: UUID!

"The Concern of the alert."
concern: Educatable! @morphTo
"The Concern of the alert."
concern: Educatable! @morphTo

"The description of the alert."
description: String!
"The description of the alert."
description: String!

"The severity of the alert."
severity: AlertSeverity!
"The severity of the alert."
severity: AlertSeverity!

"The status of the alert."
status: AlertStatus!
"The status of the alert."
status: AlertStatus!

"The suggested intervention for the alert."
suggested_intervention: String!
"The suggested intervention for the alert."
suggested_intervention: String!

"The created datetime of the alert."
created_at: DateTime
"The created datetime of the alert."
created_at: DateTime

"The updated datetime of the alert."
updated_at: DateTime
"The updated datetime of the alert."
updated_at: DateTime

"The deleted datetime of the alert."
deleted_at: DateTime
"The deleted datetime of the alert."
deleted_at: DateTime
}

input AlertConcernsQuery {
student: StudentsQuery
contact: ContactsQuery
contact: ContactsQuery
}

input AlertsQuery {
id: UUID
concern: AlertConcernsQuery @morphToRelation
concern_id: EducatableId
concern_type: EducatableType
description: String
severity: AlertSeverity
status: AlertStatus
suggested_intervention: String
created_at: DateTime
updated_at: DateTime
deleted_at: DateTime
id: UUID
concern: AlertConcernsQuery @morphToRelation
concern_id: EducatableId
concern_type: EducatableType
description: String
severity: AlertSeverity
status: AlertStatus
suggested_intervention: String
created_at: DateTime
updated_at: DateTime
deleted_at: DateTime
}

type AlertQueries {
"Find a single alert by an identifying attribute."
find(
"The value of the attribute to match."
id: UUID! @whereKey @rules(apply: ["required", "uuid", "exists:alerts"])
): Alert @find @softDeletes @canResolved(ability: "view")

"List multiple alerts."
list(where: AlertsQuery @searchBy): [Alert!]!
@paginate
@softDeletes
@canModel(ability: "viewAny")
"Find a single alert by an identifying attribute."
find(
"The value of the attribute to match."
id: UUID! @whereKey @rules(apply: ["required", "uuid", "exists:alerts"])
): Alert @find @softDeletes @canResolved(ability: "view")

"List multiple alerts."
list(where: AlertsQuery @searchBy): [Alert!]!
@paginate
@softDeletes
@canModel(ability: "viewAny")
}

extend type Query {
alert: AlertQueries! @namespaced
alert: AlertQueries! @namespaced
}

input CreateAlertInput {
"The Concern related to the alert."
concern_id: EducatableId!
@rules(
apply: [
"required"
"AdvisingApp\\Alert\\Rules\\ConcernIdExistsRule"
]
)

"The type of Concern related to the alert."
concern_type: EducatableType!
@rules(apply: ["required", "in:student,contact"])

"The description of the alert."
description: String! @rules(apply: ["required", "string"])

"The severity of the alert."
severity: AlertSeverity! @rules(apply: ["required"])

"The status of the alert."
status: AlertStatus! @rules(apply: ["required"])

"The suggested intervention for the alert."
suggested_intervention: String! @rules(apply: ["required", "string"])
"The Concern related to the alert."
concern_id: EducatableId!
@rules(
apply: ["required", "AdvisingApp\\Alert\\Rules\\ConcernIdExistsRule"]
)

"The type of Concern related to the alert."
concern_type: EducatableType! @rules(apply: ["required", "in:contact"])

"The description of the alert."
description: String! @rules(apply: ["required", "string"])

"The severity of the alert."
severity: AlertSeverity! @rules(apply: ["required"])

"The status of the alert."
status: AlertStatus! @rules(apply: ["required"])

"The suggested intervention for the alert."
suggested_intervention: String! @rules(apply: ["required", "string"])
}

input UpdateAlertInput {
"The description of the alert."
description: String @rules(apply: ["filled", "string"])
"The description of the alert."
description: String @rules(apply: ["filled", "string"])

"The severity of the alert."
severity: AlertSeverity @rules(apply: ["filled"])
"The severity of the alert."
severity: AlertSeverity @rules(apply: ["filled"])

"The status of the alert."
status: AlertStatus @rules(apply: ["filled"])
"The status of the alert."
status: AlertStatus @rules(apply: ["filled"])

"The suggested intervention for the alert."
suggested_intervention: String @rules(apply: ["filled", "string"])
"The suggested intervention for the alert."
suggested_intervention: String @rules(apply: ["filled", "string"])
}

type AlertMutations {
"Create an alert."
create(input: CreateAlertInput! @spread): Alert!
@create
@canModel(ability: "create")

"Update an alert."
update(
"The identifier of the alert you would like to update."
id: UUID! @whereKey @rules(apply: ["required", "uuid", "exists:alerts"])

"The fields you would like to update."
input: UpdateAlertInput! @spread
): Alert! @update @canFind(ability: "update", find: "id")

"Delete an alert."
delete(
"The identifier of the alert you would like to delete."
id: UUID! @whereKey @rules(apply: ["required", "uuid", "exists:alerts"])
): Alert @delete @canFind(ability: "delete", find: "id")
"Create an alert."
create(input: CreateAlertInput! @spread): Alert!
@create
@canModel(ability: "create")

"Update an alert."
update(
"The identifier of the alert you would like to update."
id: UUID! @whereKey @rules(apply: ["required", "uuid", "exists:alerts"])

"The fields you would like to update."
input: UpdateAlertInput! @spread
): Alert! @update @canFind(ability: "update", find: "id")

"Delete an alert."
delete(
"The identifier of the alert you would like to delete."
id: UUID! @whereKey @rules(apply: ["required", "uuid", "exists:alerts"])
): Alert @delete @canFind(ability: "delete", find: "id")
}

extend type Mutation {
alert: AlertMutations! @namespaced
alert: AlertMutations! @namespaced
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,14 @@
use AdvisingApp\Contact\Models\Contact;
use AdvisingApp\Alert\Events\AlertCreated;
use Illuminate\Contracts\Queue\ShouldQueue;
use AdvisingApp\StudentDataModel\Models\Student;
use AdvisingApp\Notification\Models\Subscription;
use AdvisingApp\Alert\Notifications\AlertCreatedNotification;

class NotifySubscribersOfAlertCreated implements ShouldQueue
{
public function handle(AlertCreated $event): void
{
/** @var Student|Contact $concern */
/** @var Contact $concern */
$concern = $event->alert->concern;

$concern->subscriptions?->each(function (Subscription $subscription) use ($event) {
Expand Down
3 changes: 1 addition & 2 deletions app-modules/alert/src/Models/Alert.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,13 @@
use App\Models\Scopes\LicensedToEducatable;
use App\Models\Concerns\BelongsToEducatable;
use Illuminate\Database\Eloquent\SoftDeletes;
use AdvisingApp\StudentDataModel\Models\Student;
use Illuminate\Database\Eloquent\Relations\MorphTo;
use AdvisingApp\Notification\Models\Contracts\Subscribable;
use AdvisingApp\Audit\Models\Concerns\Auditable as AuditableTrait;
use AdvisingApp\Notification\Models\Contracts\CanTriggerAutoSubscription;

/**
* @property-read Student|Contact $concern
* @property-read Contact $concern
*
* @mixin IdeHelperAlert
*/
Expand Down
2 changes: 1 addition & 1 deletion app-modules/alert/src/Rules/ConcernIdExistsRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function validate(string $attribute, mixed $value, Closure $fail): void
$morph = Relation::getMorphedModel($type);

if (! $morph) {
$fail('The concern type must be either student or contact.');
$fail('The concern type must be contact.');
} elseif ($morph::query()->whereKey($value)->doesntExist()) {
$fail('The concern does not exist.');
}
Expand Down
Loading

0 comments on commit 68841ba

Please sign in to comment.