-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #366 from canyongbs/advising-1143
[ADVISING-1143]: Add API Capabilities for Care Team
- Loading branch information
Showing
8 changed files
with
341 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
type UserCareTeam @model(class: "AdvisingApp\\CareTeam\\Models\\CareTeam") { | ||
"Unique primary key." | ||
id: ID! | ||
"The user related to this care team assignment." | ||
user: User! @belongsTo | ||
"The educatable in the user's care team." | ||
educatable: Educatable! @morphTo | ||
"The created date of the care team assignment." | ||
created_at: DateTime | ||
"The updated date of the care team assignment." | ||
updated_at: DateTime | ||
} | ||
|
||
extend type Query { | ||
"Get a care team assignment by its primary key." | ||
userCareTeam("Search by primary key." id: ID! @whereKey): UserCareTeam | ||
@find | ||
@canResolved(ability: "view") | ||
|
||
"Get all care team assignments." | ||
userCareTeams: [UserCareTeam!]! @paginate @canModel(ability: "viewAny") | ||
} | ||
|
||
extend type Mutation { | ||
"Create a new care team assignment." | ||
createUserCareTeam( | ||
"The user to add to the care team of." | ||
user_id: ID! | ||
@rules( | ||
apply: [ | ||
"required" | ||
"exists:users,id" | ||
"AdvisingApp\\CareTeam\\Rules\\UniqueCareTeamRule" | ||
] | ||
) | ||
|
||
"The educatable to add to the care team." | ||
educatable_id: ID! | ||
@rules( | ||
apply: [ | ||
"required" | ||
"AdvisingApp\\CareTeam\\Rules\\EducatableIdExistsRule" | ||
] | ||
) | ||
|
||
"The type of educatable to add to the care team." | ||
educatable_type: String! | ||
@rules(apply: ["required", "in:student,prospect"]) | ||
): UserCareTeam! @create @canModel(ability: "create") | ||
|
||
"Delete an existing care team assignment." | ||
deleteUserCareTeam( | ||
"The primary key of the care team assignment." | ||
id: ID! @whereKey | ||
): UserCareTeam @delete @canFind(ability: "delete", find: "id") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
app-modules/care-team/src/Rules/EducatableIdExistsRule.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
|
||
/* | ||
<COPYRIGHT> | ||
Copyright © 2022-2023, Canyon GBS LLC. All rights reserved. | ||
Advising App™ is licensed under the Elastic License 2.0. For more details, | ||
see https://github.com/canyongbs/advisingapp/blob/main/LICENSE. | ||
Notice: | ||
- You may not provide the software to third parties as a hosted or managed | ||
service, where the service provides users with access to any substantial set of | ||
the features or functionality of the software. | ||
- You may not move, change, disable, or circumvent the license key functionality | ||
in the software, and you may not remove or obscure any functionality in the | ||
software that is protected by the license key. | ||
- You may not alter, remove, or obscure any licensing, copyright, or other notices | ||
of the licensor in the software. Any use of the licensor’s trademarks is subject | ||
to applicable law. | ||
- Canyon GBS LLC respects the intellectual property rights of others and expects the | ||
same in return. Canyon GBS™ and Advising App™ are registered trademarks of | ||
Canyon GBS LLC, and we are committed to enforcing and protecting our trademarks | ||
vigorously. | ||
- The software solution, including services, infrastructure, and code, is offered as a | ||
Software as a Service (SaaS) by Canyon GBS LLC. | ||
- Use of this software implies agreement to the license terms and conditions as stated | ||
in the Elastic License 2.0. | ||
For more information or inquiries please visit our website at | ||
https://www.canyongbs.com or contact us via email at [email protected]. | ||
</COPYRIGHT> | ||
*/ | ||
|
||
namespace AdvisingApp\CareTeam\Rules; | ||
|
||
use Closure; | ||
use Illuminate\Contracts\Validation\DataAwareRule; | ||
use Illuminate\Contracts\Validation\ValidationRule; | ||
use Illuminate\Database\Eloquent\Relations\Relation; | ||
|
||
class EducatableIdExistsRule implements DataAwareRule, ValidationRule | ||
{ | ||
protected $data = []; | ||
|
||
public function validate(string $attribute, mixed $value, Closure $fail): void | ||
{ | ||
if ( | ||
! Relation::getMorphedModel($this->data['educatable_type'])::query() | ||
->whereKey($value) | ||
->exists() | ||
) { | ||
$fail('The educatable does not exist.'); | ||
} | ||
} | ||
|
||
public function setData(array $data): static | ||
{ | ||
$this->data = $data; | ||
|
||
return $this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?php | ||
|
||
/* | ||
<COPYRIGHT> | ||
Copyright © 2022-2023, Canyon GBS LLC. All rights reserved. | ||
Advising App™ is licensed under the Elastic License 2.0. For more details, | ||
see https://github.com/canyongbs/advisingapp/blob/main/LICENSE. | ||
Notice: | ||
- You may not provide the software to third parties as a hosted or managed | ||
service, where the service provides users with access to any substantial set of | ||
the features or functionality of the software. | ||
- You may not move, change, disable, or circumvent the license key functionality | ||
in the software, and you may not remove or obscure any functionality in the | ||
software that is protected by the license key. | ||
- You may not alter, remove, or obscure any licensing, copyright, or other notices | ||
of the licensor in the software. Any use of the licensor’s trademarks is subject | ||
to applicable law. | ||
- Canyon GBS LLC respects the intellectual property rights of others and expects the | ||
same in return. Canyon GBS™ and Advising App™ are registered trademarks of | ||
Canyon GBS LLC, and we are committed to enforcing and protecting our trademarks | ||
vigorously. | ||
- The software solution, including services, infrastructure, and code, is offered as a | ||
Software as a Service (SaaS) by Canyon GBS LLC. | ||
- Use of this software implies agreement to the license terms and conditions as stated | ||
in the Elastic License 2.0. | ||
For more information or inquiries please visit our website at | ||
https://www.canyongbs.com or contact us via email at [email protected]. | ||
</COPYRIGHT> | ||
*/ | ||
|
||
namespace AdvisingApp\CareTeam\Rules; | ||
|
||
use Closure; | ||
use AdvisingApp\CareTeam\Models\CareTeam; | ||
use Illuminate\Contracts\Validation\DataAwareRule; | ||
use Illuminate\Contracts\Validation\ValidationRule; | ||
|
||
class UniqueCareTeamRule implements DataAwareRule, ValidationRule | ||
{ | ||
protected $data = []; | ||
|
||
public function validate(string $attribute, mixed $value, Closure $fail): void | ||
{ | ||
if ( | ||
CareTeam::query() | ||
->where('educatable_id', $this->data['educatable_id']) | ||
->where('educatable_type', $this->data['educatable_type']) | ||
->where('user_id', $value) | ||
->exists() | ||
) { | ||
$fail('The user is already on the care team.'); | ||
} | ||
} | ||
|
||
public function setData(array $data): static | ||
{ | ||
$this->data = $data; | ||
|
||
return $this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
app-modules/notifications/src/Rules/SubscribableIdExistsRule.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
|
||
/* | ||
<COPYRIGHT> | ||
Copyright © 2022-2023, Canyon GBS LLC. All rights reserved. | ||
Advising App™ is licensed under the Elastic License 2.0. For more details, | ||
see https://github.com/canyongbs/advisingapp/blob/main/LICENSE. | ||
Notice: | ||
- You may not provide the software to third parties as a hosted or managed | ||
service, where the service provides users with access to any substantial set of | ||
the features or functionality of the software. | ||
- You may not move, change, disable, or circumvent the license key functionality | ||
in the software, and you may not remove or obscure any functionality in the | ||
software that is protected by the license key. | ||
- You may not alter, remove, or obscure any licensing, copyright, or other notices | ||
of the licensor in the software. Any use of the licensor’s trademarks is subject | ||
to applicable law. | ||
- Canyon GBS LLC respects the intellectual property rights of others and expects the | ||
same in return. Canyon GBS™ and Advising App™ are registered trademarks of | ||
Canyon GBS LLC, and we are committed to enforcing and protecting our trademarks | ||
vigorously. | ||
- The software solution, including services, infrastructure, and code, is offered as a | ||
Software as a Service (SaaS) by Canyon GBS LLC. | ||
- Use of this software implies agreement to the license terms and conditions as stated | ||
in the Elastic License 2.0. | ||
For more information or inquiries please visit our website at | ||
https://www.canyongbs.com or contact us via email at [email protected]. | ||
</COPYRIGHT> | ||
*/ | ||
|
||
namespace AdvisingApp\Notifications\Rules; | ||
|
||
use Closure; | ||
use Illuminate\Contracts\Validation\DataAwareRule; | ||
use Illuminate\Contracts\Validation\ValidationRule; | ||
use Illuminate\Database\Eloquent\Relations\Relation; | ||
|
||
class SubscribableIdExistsRule implements DataAwareRule, ValidationRule | ||
{ | ||
protected $data = []; | ||
|
||
public function validate(string $attribute, mixed $value, Closure $fail): void | ||
{ | ||
if ( | ||
! Relation::getMorphedModel($this->data['subscribable_type'])::query() | ||
->whereKey($value) | ||
->exists() | ||
) { | ||
$fail('The subscribable does not exist.'); | ||
} | ||
} | ||
|
||
public function setData(array $data): static | ||
{ | ||
$this->data = $data; | ||
|
||
return $this; | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
app-modules/notifications/src/Rules/UniqueSubscriptionRule.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?php | ||
|
||
/* | ||
<COPYRIGHT> | ||
Copyright © 2022-2023, Canyon GBS LLC. All rights reserved. | ||
Advising App™ is licensed under the Elastic License 2.0. For more details, | ||
see https://github.com/canyongbs/advisingapp/blob/main/LICENSE. | ||
Notice: | ||
- You may not provide the software to third parties as a hosted or managed | ||
service, where the service provides users with access to any substantial set of | ||
the features or functionality of the software. | ||
- You may not move, change, disable, or circumvent the license key functionality | ||
in the software, and you may not remove or obscure any functionality in the | ||
software that is protected by the license key. | ||
- You may not alter, remove, or obscure any licensing, copyright, or other notices | ||
of the licensor in the software. Any use of the licensor’s trademarks is subject | ||
to applicable law. | ||
- Canyon GBS LLC respects the intellectual property rights of others and expects the | ||
same in return. Canyon GBS™ and Advising App™ are registered trademarks of | ||
Canyon GBS LLC, and we are committed to enforcing and protecting our trademarks | ||
vigorously. | ||
- The software solution, including services, infrastructure, and code, is offered as a | ||
Software as a Service (SaaS) by Canyon GBS LLC. | ||
- Use of this software implies agreement to the license terms and conditions as stated | ||
in the Elastic License 2.0. | ||
For more information or inquiries please visit our website at | ||
https://www.canyongbs.com or contact us via email at [email protected]. | ||
</COPYRIGHT> | ||
*/ | ||
|
||
namespace AdvisingApp\Notifications\Rules; | ||
|
||
use Closure; | ||
use AdvisingApp\Notifications\Models\Subscription; | ||
use Illuminate\Contracts\Validation\DataAwareRule; | ||
use Illuminate\Contracts\Validation\ValidationRule; | ||
|
||
class UniqueSubscriptionRule implements DataAwareRule, ValidationRule | ||
{ | ||
protected $data = []; | ||
|
||
public function validate(string $attribute, mixed $value, Closure $fail): void | ||
{ | ||
if ( | ||
Subscription::query() | ||
->where('subscribable_id', $this->data['subscribable_id']) | ||
->where('subscribable_type', $this->data['subscribable_type']) | ||
->where('user_id', $value) | ||
->exists() | ||
) { | ||
$fail('The user is already subscribed.'); | ||
} | ||
} | ||
|
||
public function setData(array $data): static | ||
{ | ||
$this->data = $data; | ||
|
||
return $this; | ||
} | ||
} |