Ability to suppress users from checkoutable list

This commit is contained in:
snipe 2016-04-28 20:19:22 -07:00
parent 449163c875
commit 7b489ad1ec
3 changed files with 38 additions and 1 deletions

View file

@ -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);

View file

@ -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');

View file

@ -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');
});
}
}