diff --git a/app/Http/Controllers/Api/UserApiController.php b/app/Http/Controllers/Api/UserApiController.php index 76655459..afed16c0 100644 --- a/app/Http/Controllers/Api/UserApiController.php +++ b/app/Http/Controllers/Api/UserApiController.php @@ -79,7 +79,6 @@ final class UserApiController extends APICRUDController { ]; } - /** * @param $id * @return mixed @@ -205,7 +204,9 @@ final class UserApiController extends APICRUDController { 'birthday' => 'nullable|date_format:U', 'password' => 'sometimes|string|min:8|confirmed', 'email_verified' => 'nullable|boolean', - 'active' => 'nullable|boolean' + 'active' => 'nullable|boolean', + 'phone_number' => 'nullable|string', + 'company' => 'nullable|string', ]; } @@ -251,7 +252,9 @@ final class UserApiController extends APICRUDController { 'birthday' => 'nullable|date_format:U', 'password' => 'sometimes|string|min:8|confirmed', 'email_verified' => 'nullable|boolean', - 'active' => 'nullable|boolean' + 'active' => 'nullable|boolean', + 'phone_number' => 'nullable|string', + 'company' => 'nullable|string', ]; } diff --git a/app/Services/OAuth2/ResourceServer/UserService.php b/app/Services/OAuth2/ResourceServer/UserService.php index e01e0439..147cacdc 100644 --- a/app/Services/OAuth2/ResourceServer/UserService.php +++ b/app/Services/OAuth2/ResourceServer/UserService.php @@ -133,6 +133,8 @@ final class UserService extends OAuth2ProtectedService implements IUserService $data[StandardClaims::Name] = $current_user->getFullName(); $data[StandardClaims::GivenName] = $current_user->getFirstName(); $data[StandardClaims::FamilyName] = $current_user->getLastName(); + $data[StandardClaims::PhoneNumber] = $current_user->getPhoneNumber(); + $data[StandardClaims::PhoneNumberVerified] = false; $data[StandardClaims::NickName] = $current_user->getIdentifier(); $data[StandardClaims::SubjectIdentifier] = $current_user->getAuthIdentifier(); $data[StandardClaims::Picture] = $current_user->getPic(); @@ -146,6 +148,7 @@ final class UserService extends OAuth2ProtectedService implements IUserService $data[StandardClaims::GitHubUser] = $current_user->getGithubUser(); $data[StandardClaims::WeChatUser] = $current_user->getWechatUser(); $data[StandardClaims::TwitterName] = $current_user->getTwitterName(); + $data[StandardClaims::Company] = $current_user->getCompany(); $user_groups = []; diff --git a/app/libs/Auth/Factories/UserFactory.php b/app/libs/Auth/Factories/UserFactory.php index 2975f694..cb4c0c0e 100644 --- a/app/libs/Auth/Factories/UserFactory.php +++ b/app/libs/Auth/Factories/UserFactory.php @@ -118,6 +118,12 @@ final class UserFactory if(isset($payload['state'])) $user->setState(trim($payload['state'])); + if(isset($payload['phone_number'])) + $user->setPhoneNumber(trim($payload['phone_number'])); + + if(isset($payload['company'])) + $user->setCompany(trim($payload['company'])); + if(isset($payload['post_code'])) $user->setPostCode(trim($payload['post_code'])); diff --git a/app/libs/Auth/Models/User.php b/app/libs/Auth/Models/User.php index d8b5e8c2..7ba55979 100644 --- a/app/libs/Auth/Models/User.php +++ b/app/libs/Auth/Models/User.php @@ -281,6 +281,18 @@ class User extends BaseEntity */ private $spam_type; + /** + * @ORM\Column(name="company", nullable=true, type="string") + * @var string + */ + private $company; + + /** + * @ORM\Column(name="phone_number", nullable=true, type="string") + * @var string + */ + private $phone_number; + // relations /** @@ -385,6 +397,8 @@ class User extends BaseEntity $this->scope_groups = new ArrayCollection(); $this->reset_password_requests = new ArrayCollection(); $this->spam_type = self::SpamTypeNone; + $this->company = null; + $this->phone_number = null; } /** @@ -1665,5 +1679,36 @@ SQL; return $this->spam_type == self::SpamTypeSpam; } + /** + * @return string + */ + public function getCompany(): ?string + { + return $this->company; + } + + /** + * @param string $company + */ + public function setCompany(string $company): void + { + $this->company = $company; + } + + /** + * @return string + */ + public function getPhoneNumber(): ?string + { + return $this->phone_number; + } + + /** + * @param string $phone_number + */ + public function setPhoneNumber(string $phone_number): void + { + $this->phone_number = $phone_number; + } } \ No newline at end of file diff --git a/app/libs/OAuth2/StandardClaims.php b/app/libs/OAuth2/StandardClaims.php index 8e62c7ec..17021cd9 100644 --- a/app/libs/OAuth2/StandardClaims.php +++ b/app/libs/OAuth2/StandardClaims.php @@ -195,4 +195,9 @@ abstract class StandardClaims * WeChatUser */ const WeChatUser = 'wechat_user'; + + /** + * Company + */ + const Company = 'company'; } \ No newline at end of file diff --git a/database/migrations/Version20200715150546.php b/database/migrations/Version20200715150546.php new file mode 100644 index 00000000..f7c2daf4 --- /dev/null +++ b/database/migrations/Version20200715150546.php @@ -0,0 +1,51 @@ +hasTable("users") && !$builder->hasColumn("users","company") ) { + $builder->table('users', function (Table $table) { + $table->string('company')->setNotnull(false); + $table->string('phone_number')->setNotnull(false); + }); + } + } + + /** + * @param Schema $schema + */ + public function down(Schema $schema) + { + $builder = new Builder($schema); + if($schema->hasTable("users") && $builder->hasColumn("users","company") ) { + $builder->table('users', function (Table $table) { + $table->dropColumn('company'); + $table->dropColumn('phone_number'); + }); + } + } +} diff --git a/public/assets/js/admin/users.js b/public/assets/js/admin/users.js index a36cdede..d941d4e7 100644 --- a/public/assets/js/admin/users.js +++ b/public/assets/js/admin/users.js @@ -61,7 +61,7 @@ UsersCrud.prototype.constructor = UsersCrud; UsersCrud.prototype._buildFilters = function () { var term = encodeURIComponent(this.searchTerm); - return 'filter=first_name=@'+term+',last_name=@'+term+',email=@'+term; + return 'filter=first_name=@'+term+',last_name=@'+term+',email=@'+term+',full_name=@'+term; }; UsersCrud.prototype.init = function () { diff --git a/public/assets/js/basic-crud.js b/public/assets/js/basic-crud.js index ff039c02..336a24b2 100644 --- a/public/assets/js/basic-crud.js +++ b/public/assets/js/basic-crud.js @@ -157,12 +157,15 @@ BasicCrud.prototype = { $('.label-info').show(); $('#table').hide(); $('#search-container').hide(); + $('#pager-container').hide(); $('body').ajax_loader('stop'); return; } + $('.label-info').hide(); $('#table').show(); $('#search-container').show(); + $('#pager-container').show(); var body = _this.templatePage.render(items, _this.directivesPage); $('#body-table', '#table').remove(); @@ -204,7 +207,6 @@ BasicCrud.prototype = { } } }; - var pager = templatePager.render(pages, directivesPager); $('#pager', '#pager-container').remove(); diff --git a/resources/views/admin/edit-user.blade.php b/resources/views/admin/edit-user.blade.php index f406886c..8330eda5 100644 --- a/resources/views/admin/edit-user.blade.php +++ b/resources/views/admin/edit-user.blade.php @@ -139,6 +139,17 @@
+