-
Notifications
You must be signed in to change notification settings - Fork 16
Membership Approval #145
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
Merged
Membership Approval #145
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
573e957
Role: Trustee and membership team cons’s
dpslwk 21940d1
Laracast/flash: add JS for overlay
dpslwk de3adb9
Add users search api
dpslwk 775fa7b
Register: missing validation rules
dpslwk 051ed88
RoleManager: add removerUserFromRoleByName method
dpslwk 08b129e
User: make name and email public properties available on the entity
dpslwk 6ed03ca
Add update methods to User and Profile managers
dpslwk c477ada
Interest Registered email subject
dpslwk 09713ed
Membership Approval: take a member from member.approval to member.pay…
dpslwk c762129
Merge branch 'master' into approval
dpslwk 7f22d93
Membership Approval: styleCI
dpslwk 0534350
IntersRegister: update mail to markdown format
dpslwk d45308e
Membership Approval: just pass the user object to the editDetails view
dpslwk 4fe4310
Role: use .env for slack webhooks, not meta
dpslwk 911c537
Member Approval: slack notifications
dpslwk 898b221
Membership arrival: email fix
dpslwk d2d8a84
Merge branch 'master' into approval
dpslwk b2f7c87
Seeder: fix broken user seeder
dpslwk b055b03
Config: move calls for env vars out main codebase and into a general …
dpslwk 815c12d
Member Approval: typos and changes for @cooperaj
dpslwk 176a535
Merge branch 'master' into approval
dpslwk 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ | |
| use Carbon\Carbon; | ||
| use HMS\Entities\User; | ||
| use HMS\Entities\Profile; | ||
| use Illuminate\Http\Request; | ||
| use HMS\Repositories\MetaRepository; | ||
| use HMS\Repositories\UserRepository; | ||
| use HMS\Repositories\ProfileRepository; | ||
|
|
@@ -86,4 +87,66 @@ public function create(User $user, string $address1, ?string $address2, ?string | |
|
|
||
| return $user; | ||
| } | ||
|
|
||
| /** | ||
| * update the user form a form request. | ||
| * @param User $user user to update | ||
| * @param Illuminate\Http\Request $request | ||
| * @return User | ||
| */ | ||
| public function updateUserProfileFromRequest(User $user, Request $request) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Has this request been sanitized before it gets here? I forget laravels functionings. |
||
| { | ||
| $profile = $user->getProfile(); | ||
|
|
||
| if ($request['address1']) { | ||
| $profile->setAddress1($request['address1']); | ||
| } | ||
|
|
||
| // Nullable field | ||
| if ($request->exists('address2')) { | ||
| $profile->setAddress2($request['address2']); | ||
| } | ||
|
|
||
| // Nullable field | ||
| if ($request->exists('address3')) { | ||
| $profile->setAddress3($request['address3']); | ||
| } | ||
|
|
||
| if ($request['addressCity']) { | ||
| $profile->setAddressCity($request['addressCity']); | ||
| } | ||
|
|
||
| if ($request['addressCounty']) { | ||
| $profile->setAddressCounty($request['addressCounty']); | ||
| } | ||
|
|
||
| if ($request['addressPostcode']) { | ||
| $profile->setAddressPostcode($request['addressPostcode']); | ||
| } | ||
|
|
||
| if ($request['contactNumber']) { | ||
| $profile->setContactNumber($request['contactNumber']); | ||
| } | ||
|
|
||
| // Nullable field | ||
| if ($request->exists('dateOfBirth')) { | ||
| if (is_null($request['dataOfBirth'])) { | ||
| $profile->setDateOfBirth(null); | ||
| } else { | ||
| $profile->setDateOfBirth(new Carbon($request['dateOfBirth'])); | ||
| } | ||
| } | ||
|
|
||
| if ($request['creditLimit']) { | ||
| $profile->setCreditLimit($request['creditLimit']); | ||
| } | ||
|
|
||
| if ($request['unlockText']) { | ||
| $profile->setUnlockText($request['unlockText']); | ||
| } | ||
|
|
||
| $this->userRepository->save($user); | ||
|
|
||
| return $user; | ||
| } | ||
| } | ||
This file contains hidden or 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 hidden or 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,62 @@ | ||
| <?php | ||
|
|
||
| namespace App\Http\Controllers\Api; | ||
|
|
||
| use Illuminate\Http\Request; | ||
| use App\Http\Controllers\Controller; | ||
| use HMS\Repositories\UserRepository; | ||
|
|
||
| class SearchController extends Controller | ||
| { | ||
| /** | ||
| * @var UserRepository | ||
| */ | ||
| protected $userRepository; | ||
|
|
||
| /** | ||
| * Create a new controller instance. | ||
| * | ||
| * @param UserRepository $userRepository | ||
| */ | ||
| public function __construct(UserRepository $userRepository) | ||
| { | ||
| $this->userRepository = $userRepository; | ||
|
|
||
| $this->middleware('can:search.users')->only(['usersSearch']); | ||
| } | ||
|
|
||
| /** | ||
| * Search for users. | ||
| * | ||
| * @param Request $request | ||
| * @param string $searchQuery | ||
| * @return \Illuminate\Http\Response | ||
| */ | ||
| public function users(string $searchQuery = null, Request $request) | ||
| { | ||
| if ($request['q']) { | ||
| $searchQuery = $request['q']; | ||
| } elseif (is_null($searchQuery)) { | ||
| return response()->json([]); | ||
| } | ||
|
|
||
| // TODO: consider how to paginate response (posible fractal) | ||
| $users = $this->userRepository->searchLike($searchQuery, $request->input('withAccount', false)); | ||
| $json = []; | ||
|
|
||
| foreach ($users as $user) { | ||
| $json[] = [ | ||
| 'id' => $user->getId(), | ||
| 'fullname' => $user->getFullname(), | ||
| 'username' => $user->getUsername(), | ||
| 'email' => $user->getEmail(), | ||
| 'address1' => $user->getProfile() ? $user->getProfile()->getAddress1() : null, | ||
| 'addressPostcode' => $user->getProfile() ? $user->getProfile()->getAddressPostcode() : null, | ||
| 'accountId' => $user->getAccount() ? $user->getAccount()->getId() : null, | ||
| 'paymentRef' => $user->getAccount() ? $user->getAccount()->getPaymentRef() : null, | ||
| ]; | ||
| } | ||
|
|
||
| return response()->json($json); | ||
| } | ||
| } |
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.
Nullable bool?
Is this because some callers might not pass a 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'm calling with
$this->userRepository->searchLike($searchQuery, $request->input('withAccount', false))and
$request->inputcan return null