-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feat] Backend for employee profile #12334
Merged
Merged
Changes from 16 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
c5d1e76
add employee profile enums
esizer 1fb3fea
make lang file function static
esizer 20167bd
add additional enums
esizer 47a76df
add model, migration, policy for employee profile
esizer 5911175
add model, policy, migration, seeding
esizer 8179e44
fix relationships
esizer 2d9c195
update graphql schema with employee profile
esizer ef4778b
add tests for employee profile graphql
esizer 5804287
fix permissions, add test
esizer 6ae5d96
fix test case name
esizer acdbd65
fix column type
esizer 17f6def
add empty arr to lang file
esizer f7c7b64
add translations
esizer 2a201f4
fix graphql input for employee profile
esizer 9f63e14
add mentee to dictionary
esizer 224b3cc
try another can directive
esizer 785c731
fix down migration
esizer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
|
@@ -41,6 +41,7 @@ Laratrust | |
Laravel | ||
Lcobucci | ||
licences | ||
MENTEE | ||
Métis | ||
Mi'kmaw | ||
Michif | ||
|
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,18 @@ | ||
<?php | ||
|
||
namespace App\Enums; | ||
|
||
use App\Traits\HasLocalization; | ||
|
||
enum ExecCoaching | ||
{ | ||
use HasLocalization; | ||
|
||
case COACHING; | ||
case LEARNING; | ||
|
||
public static function getLangFilename(): string | ||
{ | ||
return 'exec_coaching'; | ||
} | ||
} |
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,18 @@ | ||
<?php | ||
|
||
namespace App\Enums; | ||
|
||
use App\Traits\HasLocalization; | ||
|
||
enum Mentorship | ||
{ | ||
use HasLocalization; | ||
|
||
case MENTOR; | ||
case MENTEE; | ||
mnigh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
public static function getLangFilename(): string | ||
{ | ||
return 'mentorship'; | ||
} | ||
} |
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,19 @@ | ||
<?php | ||
|
||
namespace App\Enums; | ||
|
||
use App\Traits\HasLocalization; | ||
|
||
enum MoveInterest | ||
{ | ||
use HasLocalization; | ||
|
||
case ABOVE_LEVEL; | ||
case AT_LEVEL; | ||
case BELOW_LEVEL; | ||
|
||
public static function getLangFilename(): string | ||
{ | ||
return 'move_interest'; | ||
} | ||
} |
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,20 @@ | ||
<?php | ||
|
||
namespace App\Enums; | ||
|
||
use App\Traits\HasLocalization; | ||
|
||
enum OrganizationTypeInterest | ||
{ | ||
use HasLocalization; | ||
|
||
case CURRENT; | ||
case OTHER_DEPARTMENT; | ||
case OTHER_AGENCY; | ||
case OTHER_CROWN_CORP; | ||
|
||
public static function getLangFilename(): string | ||
{ | ||
return 'organization_type_interest'; | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
api/app/GraphQL/Validators/UpdateEmployeeProfileInputValidator.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 | ||
|
||
namespace App\GraphQL\Validators; | ||
|
||
use App\Enums\ExecCoaching; | ||
use App\Enums\Mentorship; | ||
use App\Enums\MoveInterest; | ||
use App\Enums\OrganizationTypeInterest; | ||
use App\Models\WorkStream; | ||
use Database\Helpers\ApiErrorEnums; | ||
use Illuminate\Validation\Rule; | ||
use Nuwave\Lighthouse\Validation\Validator; | ||
|
||
final class UpdateEmployeeProfileInputValidator extends Validator | ||
{ | ||
/** | ||
* Return the validation rules. | ||
* | ||
* @return array<string, array<mixed>> | ||
*/ | ||
public function rules(): array | ||
{ | ||
$communityId = $this->arg('dreamRoleCommunity.connect'); | ||
$workStreams = $communityId ? WorkStream::where('community_id', $communityId)->get('id')->pluck('id') : []; | ||
|
||
return [ | ||
'organizationTypeInterest' => ['nullable'], | ||
'organizationTypeInterest.*' => [Rule::in(array_column(OrganizationTypeInterest::cases(), 'name'))], | ||
'moveInterest' => ['nullable'], | ||
'moveInterest.*' => [Rule::in(array_column(MoveInterest::cases(), 'name'))], | ||
'mentorshipStatus' => ['nullable'], | ||
'mentorshipStatus.*' => [Rule::in(array_column(Mentorship::cases(), 'name'))], | ||
'mentorshipInterest' => ['nullable'], | ||
'mentorshipInterest.*' => [Rule::in(array_column(Mentorship::cases(), 'name'))], | ||
'execInterest' => ['nullable', 'boolean'], | ||
'execCoachingStatus' => ['nullable'], | ||
'execCoachingStatus.*' => [Rule::in(array_column(ExecCoaching::cases(), 'name'))], | ||
'execCoachingInterest' => ['nullable'], | ||
'execCoachingInterest.*' => [Rule::in(array_column(ExecCoaching::cases(), 'name'))], | ||
|
||
'dreamRoleTitle' => ['nullable', 'string'], | ||
'dreamRoleAdditionalInformation' => ['nullable', 'string'], | ||
'dreamRoleCommunity.connect' => ['uuid', 'exists:communities,id'], | ||
'dreamRoleClassification.connect' => ['uuid', 'exists:classifications,id'], | ||
'dreamRoleWorkStream.connect' => ['prohibited_if:dreamRoleCommunity,null', 'uuid', 'exists:work_streams,id', Rule::in($workStreams)], | ||
'dreamRoleDepartments.sync.*' => ['uuid', 'exists:departments,id'], | ||
|
||
'aboutYou' => ['nullable', 'string'], | ||
'careerGoals' => ['nullable', 'string'], | ||
'learningGoals' => ['nullable', 'string'], | ||
'workStyle' => ['nullable', 'string'], | ||
]; | ||
} | ||
|
||
public function messages(): array | ||
{ | ||
return [ | ||
'dreamRoleCommunity.connect.exists' => ApiErrorEnums::COMMUNITY_NOT_FOUND, | ||
'dreamRoleClassification.connect.exists' => ApiErrorEnums::CLASSIFICATION_NOT_FOUND, | ||
'dreamRoleWorkStream.connect.exists' => ApiErrorEnums::WORK_STREAM_NOT_FOUND, | ||
'dreamRoleWorkStream.connect.in' => ApiErrorEnums::WORK_STREAM_NOT_IN_COMMUNITY, | ||
'dreamRoleDepartments.sync.*.exists' => ApiErrorEnums::DEPARTMENT_NOT_FOUND, | ||
]; | ||
} | ||
} |
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,73 @@ | ||
<?php | ||
|
||
namespace App\Models; | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
use Illuminate\Database\Eloquent\Relations\BelongsTo; | ||
use Illuminate\Database\Eloquent\Relations\BelongsToMany; | ||
use Illuminate\Database\Eloquent\Relations\HasOne; | ||
|
||
/** | ||
* Class EmployeeProfile | ||
* | ||
* @property string $id | ||
* @property ?array $career_planning_organization_type_interest | ||
* @property ?array $career_planning_move_interest | ||
* @property ?array $career_planning_mentorship_status | ||
* @property ?array $career_planning_mentorship_interest | ||
* @property ?bool $career_planning_exec_interest | ||
* @property ?array $career_planning_exec_coaching_status | ||
* @property ?array $career_planning_exec_coaching_interest | ||
* @property string $career_planning_about_you | ||
* @property string $career_planning_career_goals | ||
* @property string $career_planning_learning_goals | ||
* @property string $career_planning_work_style | ||
* @property string $dream_role_title | ||
* @property string $dream_role_additional_information | ||
*/ | ||
class EmployeeProfile extends Model | ||
{ | ||
protected $table = 'users'; | ||
|
||
protected $keyType = 'string'; | ||
|
||
protected $casts = [ | ||
'career_planning_organization_type_interest' => 'array', | ||
'career_planning_move_interest' => 'array', | ||
'career_planning_mentorship_status' => 'array', | ||
'career_planning_mentorship_interest' => 'array', | ||
'career_planning_exec_interest' => 'boolean', | ||
'career_planning_exec_coaching_status' => 'array', | ||
'career_planning_exec_coaching_interest' => 'array', | ||
]; | ||
|
||
/** @return BelongsTo<Community, $this> */ | ||
public function dreamRoleCommunity(): BelongsTo | ||
{ | ||
return $this->belongsTo(Community::class, 'dream_role_community_id'); | ||
} | ||
|
||
/** @return BelongsTo<Classification, $this> */ | ||
public function dreamRoleClassification(): BelongsTo | ||
{ | ||
return $this->belongsTo(Classification::class, 'dream_role_classification_id'); | ||
} | ||
|
||
/** @return BelongsTo<WorkStream, $this> */ | ||
public function dreamRoleWorkStream(): BelongsTo | ||
{ | ||
return $this->belongsTo(WorkStream::class, 'dream_role_work_stream_id'); | ||
} | ||
|
||
/** @return BelongsToMany<Department, $this> */ | ||
public function dreamRoleDepartments(): BelongsToMany | ||
{ | ||
return $this->belongsToMany(Department::class, 'department_user_dream_role', 'user_id', 'department_id'); | ||
} | ||
|
||
/** @return HasOne<User, $this> */ | ||
public function userPublicProfile(): HasOne | ||
{ | ||
return $this->hasOne(User::class, 'id')->select(['email', 'firstName', 'lastName']); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
namespace App\Policies; | ||
|
||
use App\Models\EmployeeProfile; | ||
use App\Models\User; | ||
|
||
class EmployeeProfilePolicy | ||
{ | ||
/** | ||
* Determine whether the user can view the model. | ||
*/ | ||
public function view(User $user, EmployeeProfile $employeeProfile): bool | ||
{ | ||
return $user->isAbleTo('view-own-employeeProfile') && $employeeProfile->id === $user->id; | ||
} | ||
|
||
/** | ||
* Determine whether the user can update the model. | ||
*/ | ||
public function update(User $user, EmployeeProfile $employeeProfile): bool | ||
{ | ||
return $user->isAbleTo('update-own-employeeProfile') && $employeeProfile->id === $user->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
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exec coaching status
same question as Mentorship status below
Are we not storing Not participating as sep enum value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I envisioned it being an array.
[]
= not participatingnull
= not providedThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that works as well!