mirror of
https://gitlab.com/signalytic/client-external/streamline/streamline-emr.git
synced 2026-09-11 18:51:31 +00:00
36 lines
1.0 KiB
PHP
Executable File
36 lines
1.0 KiB
PHP
Executable File
<?php
|
|
namespace Database\Seeders;
|
|
|
|
use Illuminate\Database\Seeder;
|
|
use Streamline\Models\User;
|
|
use Streamline\Models\PasswordSecurity;
|
|
use Carbon\Carbon;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
class PasswordExpirationForExistingUsersSeeder extends Seeder
|
|
{
|
|
/**
|
|
* Run the database seeders.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function run()
|
|
{
|
|
$existing_user_ids_array = DB::table('users')->pluck('id')->toArray();
|
|
|
|
$user_ids_in_password_securities_table_array = DB::table('users')
|
|
->join('password_securities','password_securities.user_id', '=', 'users.id')
|
|
->pluck('users.id')->toArray();
|
|
|
|
for ($i=0; $i < count($existing_user_ids_array) ; $i++) {
|
|
if (!in_array($existing_user_ids_array[$i], $user_ids_in_password_securities_table_array)) {
|
|
PasswordSecurity::create([
|
|
'user_id' => $existing_user_ids_array[$i],
|
|
'password_expiry_days' => 30,
|
|
'password_updated_at' => Carbon::now(),
|
|
]);
|
|
}
|
|
}
|
|
}
|
|
}
|