Skip to content

A free open source IT asset/license management system

Ability to suppress users from checkoutable list

snipe7b489ad1ec7c
diff --git a/app/Console/Commands/CreateAdmin.php b/app/Console/Commands/CreateAdmin.php
index 9fc73d167e..4402e0e7af 100644
--- a/app/Console/Commands/CreateAdmin.php
+++ b/app/Console/Commands/CreateAdmin.php
@@ -11,7 +11,7 @@ class CreateAdmin extends Command
*
* @var string
*/
- protected $signature = 'snipeit:create-admin {--first_name=} {--last_name=} {--email=} {--username=} {--password=}';
+ protected $signature = 'snipeit:create-admin {--first_name=} {--last_name=} {--email=} {--username=} {--password=} {show_in_list?}';
/**
* The console command description.
@@ -43,6 +43,7 @@ class CreateAdmin extends Command
$username = $this->option('username');
$email = $this->option('email');
$password = $this->option('password');
+ $show_in_list = $this->argument('show_in_list');
if (($first_name=='') || ($last_name=='') || ($username=='') || ($email=='') || ($password=='')) {
$this->info('ERROR: All fields are required.');
@@ -55,6 +56,10 @@ class CreateAdmin extends Command
$user->permissions = '{"admin":1,"user":1,"superuser":1,"reports":1}';
$user->password = bcrypt($password);
$user->activated = 1;
+
+ if ($show_in_list == 'false') {
+ $user->show_in_list = 0;
+ }
if ($user->save()) {
$this->info('New user created');
$user->groups()->attach(1);
diff --git a/app/Helpers/Helper.php b/app/Helpers/Helper.php
index 86cd791128..478462560b 100644
--- a/app/Helpers/Helper.php
+++ b/app/Helpers/Helper.php
@@ -142,6 +142,7 @@ class Helper
$users_list = array('' => trans('general.select_user')) + DB::table('users')
->select(DB::raw('concat(last_name,", ",first_name," (",username,")") as full_name, id'))
->whereNull('deleted_at')
+ ->where('show_in_list','=',1)
->orderBy('last_name', 'asc')
->orderBy('first_name', 'asc')
->pluck('full_name', 'id');
diff --git a/database/migrations/2016_04_28_141554_add_show_to_users.php b/database/migrations/2016_04_28_141554_add_show_to_users.php
new file mode 100644
index 0000000000..52b80d6fd9
--- /dev/null
+++ b/database/migrations/2016_04_28_141554_add_show_to_users.php
@@ -0,0 +1,31 @@
+<?php
+
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class AddShowToUsers extends Migration
+{
+ /**
+ * Run the migrations.
+ *
+ * @return void
+ */
+ public function up()
+ {
+ Schema::table('users', function (Blueprint $table) {
+ $table->boolean('show_in_list')->default(1);
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public function down()
+ {
+ Schema::table('users', function ($table) {
+ $table->dropColumn('show_in_list');
+ });
+ }
+}