| Total Complexity | 2 |
| Total Lines | 41 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 9 | class AddPasswordChangeToUsers extends Migration |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * Run the migrations. |
||
| 13 | * |
||
| 14 | * @return void |
||
| 15 | */ |
||
| 16 | public function up() |
||
| 17 | { |
||
| 18 | Schema::table('users', function(Blueprint $table) |
||
| 19 | { |
||
| 20 | $table->timestamp('password_expires') |
||
| 21 | ->nullable() |
||
| 22 | ->after('active'); |
||
| 23 | }); |
||
| 24 | |||
| 25 | // Add the epiration timer to the settings database table |
||
| 26 | Settings::insert([ |
||
| 27 | 'key' => 'users.passExpires', |
||
| 28 | 'value' => '90' |
||
| 29 | ]); |
||
| 30 | |||
| 31 | // Update all of the existing users to set the password expiration date |
||
| 32 | User::where('password_expires', null)->update([ |
||
| 33 | 'password_expires' => date('Y-m-d', strtotime('+30 days')) |
||
| 34 | ]); |
||
| 35 | } |
||
| 36 | |||
| 37 | /** |
||
| 38 | * Reverse the migrations. |
||
| 39 | * |
||
| 40 | * @return void |
||
| 41 | */ |
||
| 42 | public function down() |
||
| 50 | } |
||
| 51 | } |
||
| 52 |