mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-09 23:24:06 -08:00
Ability to suppress users from checkoutable list
This commit is contained in:
parent
449163c875
commit
7b489ad1ec
|
@ -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);
|
||||
|
|
|
@ -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');
|
||||
|
|
31
database/migrations/2016_04_28_141554_add_show_to_users.php
Normal file
31
database/migrations/2016_04_28_141554_add_show_to_users.php
Normal 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');
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue