Skip to content

Commit 682baec

Browse files
authored
Merge pull request #17569 from grokability/#10284-add-mobile-number
Fixed #10284: Added mobile phone to users
2 parents f12a3bb + ff91be4 commit 682baec

File tree

15 files changed

+100
-0
lines changed

15 files changed

+100
-0
lines changed

app/Helpers/IconHelper.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ public static function icon($type) {
4343
return 'fa-regular fa-envelope';
4444
case 'phone':
4545
return 'fa-solid fa-phone';
46+
case 'mobile':
47+
return 'fas fa-mobile-screen-button';
4648
case 'long-arrow-right':
4749
return 'fas fa-long-arrow-alt-right';
4850
case 'download':

app/Http/Controllers/Api/UsersController.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ public function index(Request $request) : array
7070
'users.notes',
7171
'users.permissions',
7272
'users.phone',
73+
'users.mobile',
7374
'users.state',
7475
'users.two_factor_enrolled',
7576
'users.two_factor_optin',
@@ -121,6 +122,14 @@ public function index(Request $request) : array
121122
$users = $users->where('users.company_id', '=', $request->input('company_id'));
122123
}
123124

125+
if ($request->filled('phone')) {
126+
$users = $users->where('users.phone', '=', $request->input('phone'));
127+
}
128+
129+
if ($request->filled('mobile')) {
130+
$users = $users->where('users.mobile', '=', $request->input('mobile'));
131+
}
132+
124133
if ($request->filled('location_id')) {
125134
$users = $users->where('users.location_id', '=', $request->input('location_id'));
126135
}
@@ -293,6 +302,7 @@ public function index(Request $request) : array
293302
'manages_users_count',
294303
'manages_locations_count',
295304
'phone',
305+
'mobile',
296306
'address',
297307
'city',
298308
'state',

app/Http/Controllers/Users/UsersController.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ public function store(SaveUserRequest $request)
9898
$user->activated = $request->input('activated', 0);
9999
$user->jobtitle = $request->input('jobtitle');
100100
$user->phone = $request->input('phone');
101+
$user->mobile = $request->input('mobile');
101102
$user->location_id = $request->input('location_id', null);
102103
$user->department_id = $request->input('department_id', null);
103104
$user->company_id = Company::getIdForUser($request->input('company_id', null));
@@ -244,6 +245,7 @@ public function update(SaveUserRequest $request, User $user)
244245
$user->employee_num = $request->input('employee_num');
245246
$user->jobtitle = $request->input('jobtitle', null);
246247
$user->phone = $request->input('phone');
248+
$user->mobile = $request->input('mobile');
247249
$user->location_id = $request->input('location_id', null);
248250
$user->company_id = Company::getIdForUser($request->input('company_id', null));
249251
$user->manager_id = $request->input('manager_id', null);

app/Http/Transformers/UsersTransformer.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public function transformUser(User $user)
4545
'jobtitle' => ($user->jobtitle) ? e($user->jobtitle) : null,
4646
'vip' => ($user->vip == '1') ? true : false,
4747
'phone' => ($user->phone) ? e($user->phone) : null,
48+
'mobile' => ($user->mobile) ? e($user->mobile) : null,
4849
'website' => ($user->website) ? e($user->website) : null,
4950
'address' => ($user->address) ? e($user->address) : null,
5051
'city' => ($user->city) ? e($user->city) : null,

app/Importer/UserImporter.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public function createUserIfNotExists(array $row)
5252
$this->item['email'] = trim($this->findCsvMatch($row, 'email'));
5353
$this->item['gravatar'] = trim($this->findCsvMatch($row, 'gravatar'));
5454
$this->item['phone'] = trim($this->findCsvMatch($row, 'phone_number'));
55+
$this->item['mobile'] = trim($this->findCsvMatch($row, 'mobile_number'));
5556
$this->item['website'] = trim($this->findCsvMatch($row, 'website'));
5657
$this->item['jobtitle'] = trim($this->findCsvMatch($row, 'jobtitle'));
5758
$this->item['address'] = trim($this->findCsvMatch($row, 'address'));

app/Livewire/Importer.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@ public function mount()
334334
'manager_username' => trans('general.importer.manager_username'),
335335
'notes' => trans('general.notes'),
336336
'phone_number' => trans('admin/users/table.phone'),
337+
'mobile_number' => trans('admin/users/table.mobile'),
337338
'remote' => trans('admin/users/general.remote'),
338339
'start_date' => trans('general.start_date'),
339340
'state' => trans('general.state'),
@@ -510,6 +511,13 @@ public function mount()
510511
'telephone',
511512
'tel.',
512513
],
514+
'mobile_number' =>
515+
[
516+
'mobile',
517+
'mobile number',
518+
'cell',
519+
'cellphone',
520+
],
513521

514522
'serial' =>
515523
[

app/Models/User.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
7070
'manager_id',
7171
'password',
7272
'phone',
73+
'mobile',
7374
'notes',
7475
'state',
7576
'username',
@@ -139,6 +140,7 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
139140
'locale',
140141
'notes',
141142
'phone',
143+
'mobile',
142144
'state',
143145
'username',
144146
'website',

app/Presenters/UserPresenter.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,15 @@ public static function dataTableLayout()
124124
'visible' => true,
125125
'formatter' => 'phoneFormatter',
126126
],
127+
[
128+
'field' => 'mobile',
129+
'searchable' => true,
130+
'sortable' => true,
131+
'switchable' => true,
132+
'title' => trans('admin/users/table.mobile'),
133+
'visible' => false,
134+
'formatter' => 'mobileFormatter',
135+
],
127136
[
128137
'field' => 'website',
129138
'searchable' => true,

database/factories/UserFactory.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public function definition()
3535
'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
3636
'permissions' => '{}',
3737
'phone' => $this->faker->phoneNumber(),
38+
'mobile' => $this->faker->phoneNumber(),
3839
'state' => $this->faker->stateAbbr(),
3940
'username' => $this->faker->unique()->username(),
4041
'zip' => $this->faker->postcode(),
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
return new class extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*/
12+
public function up(): void
13+
{
14+
Schema::table('users', function (Blueprint $table) {
15+
if (!Schema::hasColumn('users', 'mobile')) {
16+
$table->text('mobile')->after('phone')->nullable()->default(null);
17+
}
18+
});
19+
}
20+
21+
/**
22+
* Reverse the migrations.
23+
*/
24+
public function down(): void
25+
{
26+
Schema::table('users', function (Blueprint $table) {
27+
$table->dropColumn('mobile');
28+
});
29+
}
30+
};

0 commit comments

Comments
 (0)