diff --git a/db/factories/AngelTypeFactory.php b/db/factories/AngelTypeFactory.php index 13944157..a25bac17 100644 --- a/db/factories/AngelTypeFactory.php +++ b/db/factories/AngelTypeFactory.php @@ -24,7 +24,7 @@ class AngelTypeFactory extends Factory 'restricted' => $this->faker->boolean(), 'requires_driver_license' => $this->faker->boolean(), - 'no_self_signup' => $this->faker->boolean(), + 'shift_self_signup' => $this->faker->boolean(), 'show_on_dashboard' => $this->faker->boolean(), 'hide_register' => $this->faker->boolean(), ]; diff --git a/db/migrations/2023_08_26_000000_angeltypes_rename_no_self_signup_to_shift_self_signup.php b/db/migrations/2023_08_26_000000_angeltypes_rename_no_self_signup_to_shift_self_signup.php new file mode 100644 index 00000000..8b9edba3 --- /dev/null +++ b/db/migrations/2023_08_26_000000_angeltypes_rename_no_self_signup_to_shift_self_signup.php @@ -0,0 +1,41 @@ +schema->table('angel_types', function (Blueprint $table): void { + $table->renameColumn('no_self_signup', 'shift_self_signup')->default(true); + $connection = $this->schema->getConnection(); + $connection->table('angel_types') + ->update(['no_self_signup' => $connection->raw('NOT no_self_signup'), + ]); + }); + } + + /** + * Reverse the migration + */ + public function down(): void + { + $this->schema->table('angel_types', function (Blueprint $table): void { + $table->renameColumn('shift_self_signup', 'no_self_signup'); + $connection = $this->schema->getConnection(); + $connection->table('angel_types') + ->update(['shift_self_signup' => $connection->raw('NOT shift_self_signup'), + ]); + }); + } +} diff --git a/includes/controller/angeltypes_controller.php b/includes/controller/angeltypes_controller.php index 3d820446..89b6478a 100644 --- a/includes/controller/angeltypes_controller.php +++ b/includes/controller/angeltypes_controller.php @@ -118,7 +118,7 @@ function angeltype_edit_controller() } $angeltype->restricted = $request->has('restricted'); - $angeltype->no_self_signup = $request->has('no_self_signup'); + $angeltype->shift_self_signup = $request->has('shift_self_signup'); $angeltype->show_on_dashboard = $request->has('show_on_dashboard'); $angeltype->hide_register = $request->has('hide_register'); @@ -138,7 +138,7 @@ function angeltype_edit_controller() success('Angel type saved.'); engelsystem_log( 'Saved angeltype: ' . $angeltype->name . ($angeltype->restricted ? ', restricted' : '') - . ($angeltype->no_self_signup ? ', no_self_signup' : '') + . ($angeltype->shift_self_signup ? ', shift_self_signup' : '') . ($angeltype->requires_driver_license ? ', requires driver license' : '') . ', ' . ($angeltype->requires_ifsg_certificate ? ', requires ifsg certificate' : '') . ', ' . $angeltype->contact_name . ', ' @@ -318,7 +318,7 @@ function angeltypes_list_controller() } $angeltype->is_restricted = $angeltype->restricted ? icon('mortarboard-fill') : ''; - $angeltype->no_self_signup_allowed = $angeltype->no_self_signup ? '' : icon('pencil-square'); + $angeltype->shift_self_signup_allowed = $angeltype->shift_self_signup ? icon('pencil-square') : ''; $angeltype->name = '', + $angeltype->shift_self_signup + ), $supporter_mode ? form_info( __('Requires driver license'), @@ -571,11 +577,11 @@ function AngelTypes_list_view($angeltypes, bool $admin_angeltypes) button(url('/angeltypes/about'), __('angeltypes.about')), ]), table([ - 'name' => __('Name'), - 'is_restricted' => icon('mortarboard-fill') . __('Requires introduction'), - 'no_self_signup_allowed' => icon('pencil-square') . __('Self Sign Up Allowed'), - 'membership' => __('Membership'), - 'actions' => '', + 'name' => __('Name'), + 'is_restricted' => icon('mortarboard-fill') . __('Requires introduction'), + 'shift_self_signup_allowed' => icon('pencil-square') . __('shift.self_signup.allowed'), + 'membership' => __('Membership'), + 'actions' => '', ], $angeltypes), ], true); } diff --git a/resources/lang/de_DE/default.po b/resources/lang/de_DE/default.po index 53c8995f..5b2348bf 100644 --- a/resources/lang/de_DE/default.po +++ b/resources/lang/de_DE/default.po @@ -1303,8 +1303,18 @@ msgstr "" "Engeltypen, welche eine Einführung benötigen, müssen von einem Supporter freigeschaltet werden " "(double-opt-in)." -msgid "No Self Sign Up allowed" -msgstr "Kein Selbst-Eintragen erlaubt" +msgid "shift.self_signup" +msgstr "Schichten selbst eintragen" + +msgid "shift.self_signup.allowed" +msgstr "Schichten selbst eintragen erlaubt" + +msgid "angeltypes.shift.self_signup.info" +msgstr "Engeltypen, welche Schichten selbst eintragen erlaubt haben, " +"erlauben Engeln sich selbst in ihre Schichten einzutragen, " +"ist Schichten selbst eintragen nicht erlaubt können nur Supporter " +"oder Admins Engel in die Schichten des Engeltyps eintragen." + msgid "Requires driver license" msgstr "Benötigt Führerschein" diff --git a/resources/lang/en_US/default.po b/resources/lang/en_US/default.po index e96eb415..980bb85f 100644 --- a/resources/lang/en_US/default.po +++ b/resources/lang/en_US/default.po @@ -531,6 +531,16 @@ msgstr "DECT" msgid "angeltypes.email" msgstr "E-Mail" +msgid "angeltypes.shift.self_signup.info" +msgstr "Angel types which have shift self signup enabled allow angels to self sign up for there shifts, " +"if shift self signup is disabled only supporters and admins can sign angels into shifts of these angel types." + +msgid "shift.self_signup" +msgstr "Shift self signup" + +msgid "shift.self_signup.allowed" +msgstr "Shift self signup allowed" + msgid "registration.register" msgstr "Register" diff --git a/src/Models/AngelType.php b/src/Models/AngelType.php index a1f41436..bcbcc3f0 100644 --- a/src/Models/AngelType.php +++ b/src/Models/AngelType.php @@ -24,7 +24,7 @@ use Illuminate\Database\Query\Builder as QueryBuilder; * @property boolean $restricted # If users need an introduction * @property boolean $requires_driver_license # If users must have a driver license * @property boolean $requires_ifsg_certificate # If users must have a ifsg certificate - * @property boolean $no_self_signup # Users can sign up for shifts + * @property boolean $shift_self_signup # Users can sign up for shifts * @property boolean $show_on_dashboard # Show on public dashboard * @property boolean $hide_register # Hide from registration page * @@ -49,7 +49,21 @@ class AngelType extends BaseModel { use HasFactory; - /** @var array */ + /** @var array Default attributes */ + protected $attributes = [ // phpcs:ignore + 'restricted' => false, + 'requires_driver_license' => false, + 'requires_ifsg_certificate' => false, + 'shift_self_signup' => true, + 'show_on_dashboard' => false, + 'hide_register' => false, + ]; + + /** + * The attributes that are mass assignable. + * + * @var array + */ protected $fillable = [ // phpcs:ignore 'name', 'description', @@ -61,7 +75,7 @@ class AngelType extends BaseModel 'restricted', 'requires_driver_license', 'requires_ifsg_certificate', - 'no_self_signup', + 'shift_self_signup', 'show_on_dashboard', 'hide_register', ]; @@ -71,7 +85,7 @@ class AngelType extends BaseModel 'restricted' => 'boolean', 'requires_driver_license' => 'boolean', 'requires_ifsg_certificate' => 'boolean', - 'no_self_signup' => 'boolean', + 'shift_self_signup' => 'boolean', 'show_on_dashboard' => 'boolean', 'hide_register' => 'boolean', ];