diff --git a/app/Database/factories/RoleFactory.php b/app/Database/factories/RoleFactory.php new file mode 100644 index 00000000..7373766b --- /dev/null +++ b/app/Database/factories/RoleFactory.php @@ -0,0 +1,13 @@ +define(App\Models\Role::class, function (Faker $faker) { + return [ + 'id' => null, + 'name' => $faker->name, + 'display_name' => $faker->name, + 'read_only' => false, + 'disable_activity_checks' => $faker->boolean(), + ]; +}); diff --git a/app/Database/migrations/2021_03_18_161419_add_disableactivitychecks_to_roles.php b/app/Database/migrations/2021_03_18_161419_add_disableactivitychecks_to_roles.php new file mode 100644 index 00000000..72318d42 --- /dev/null +++ b/app/Database/migrations/2021_03_18_161419_add_disableactivitychecks_to_roles.php @@ -0,0 +1,34 @@ +boolean('disable_activity_checks') + ->default(false) + ->after('read_only'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('roles', function (Blueprint $table) { + $table->dropColumn('disable_activity_checks'); + }); + } +} diff --git a/app/Models/Role.php b/app/Models/Role.php index f2684a38..65454112 100644 --- a/app/Models/Role.php +++ b/app/Models/Role.php @@ -5,6 +5,12 @@ namespace App\Models; use Laratrust\Models\LaratrustRole; /** + * @property int id + * @property string name + * @property string display_name + * @property bool read_only + * @property bool disable_activity_checks + * * @mixin \Illuminate\Database\Eloquent\Builder */ class Role extends LaratrustRole @@ -14,10 +20,12 @@ class Role extends LaratrustRole 'name', 'display_name', 'read_only', + 'disable_activity_checks', ]; protected $casts = [ - 'read_only' => 'boolean', + 'read_only' => 'boolean', + 'disable_activity_checks' => 'boolean', ]; /** diff --git a/app/Services/UserService.php b/app/Services/UserService.php index fdfb91c8..275117cf 100644 --- a/app/Services/UserService.php +++ b/app/Services/UserService.php @@ -282,9 +282,24 @@ class UserService extends Service } // See if the difference is larger than what the setting calls for - if ($date->diffInDays($diff_date) > $leave_days) { - $return_users[] = $user; + if ($date->diffInDays($diff_date) <= $leave_days) { + continue; } + + $skip = false; + // If any role for this user has the "disable_activity_check" feature activated, skip this user + foreach ($user->roles()->get() as $role) { + /** @var Role $role */ + if ($role->disable_activity_checks) { + $skip = true; + break; + } + } + + if ($skip) { + continue; + } + $return_users[] = $user; } return $return_users; diff --git a/resources/views/admin/roles/fields.blade.php b/resources/views/admin/roles/fields.blade.php index 929c6598..69ebe526 100644 --- a/resources/views/admin/roles/fields.blade.php +++ b/resources/views/admin/roles/fields.blade.php @@ -14,6 +14,23 @@ +
{{ $errors->first('disable_activity_checks') }}
+