Skip to content

Fix validation of URLs and translations of validation messages #33

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/Http/Requests/BookingOptionRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public function rules(): array
'available_from' => [
'nullable',
'date_format:Y-m-d\TH:i',
'required_with:available_until',
],
'available_until' => [
'nullable',
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Requests/EventRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,15 @@ public function rules(): array
'started_at' => [
'nullable',
'date_format:Y-m-d\TH:i',
'required_with:finished_at',
],
'finished_at' => [
'nullable',
'date_format:Y-m-d\TH:i',
],
'website_url' => [
'nullable',
'string',
'url:http,https',
'max:255',
],
'location_id' => [
Expand Down
9 changes: 8 additions & 1 deletion app/Http/Requests/GenerateGroupsRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,15 @@ public function rules(): array

public function attributes(): array
{
return [
$attributes = [
'booking_option_id' => __('Booking options'),
'exclude_parent_group_id' => __('Exclude members of groups'),
];

foreach (range(0, count($this->input('exclude_parent_group_id')) - 1) as $id) {
$attributes['exclude_parent_group_id.' . $id] = __('Exclude members of groups');
}

return $attributes;
}
}
7 changes: 3 additions & 4 deletions app/Http/Requests/LocationRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,18 @@ class LocationRequest extends FormRequest
*/
public function rules(): array
{
$rules = [
return [
'name' => [
'nullable',
'string',
'max:255',
],
'website_url' => [
'nullable',
'string',
'url:http,https',
'max:255',
],
...$this->rulesForAddressFields('nullable'),
];

return array_replace($rules, $this->rulesForAddressFields('nullable'));
}
}
2 changes: 1 addition & 1 deletion app/Http/Requests/OrganizationRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function rules(): array
],
'website_url' => [
'nullable',
'string',
'url:http,https',
'max:255',
],
'location_id' => [
Expand Down
2 changes: 2 additions & 0 deletions lang/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
"Edit users": "Benutzer bearbeiten",
"email field": "E-Mail-Feld",
"End date": "Enddatum",
"End of the booking period": "Ende des Anmeldezeitraums",
"End of the period": "Ende des Zeitraums",
"Event": "Veranstaltung",
"Event series": "Veranstaltungsreihen",
Expand Down Expand Up @@ -244,6 +245,7 @@
"Sorting": "Sortierung",
"spreadsheet": "Tabellenkalkulation",
"Start date": "Startdatum",
"Start of the booking period": "Beginn des Anmeldezeitraums",
"Start of the period": "Beginn des Zeitraums",
"Status": "Status",
"Street": "Straße",
Expand Down
19 changes: 17 additions & 2 deletions lang/de/validation.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,12 @@
'abilities' => 'Berechtigungen',
'address' => 'Adresse',
'approval_status' => 'Freigabestatus',
'available_from' => 'Beginn des Anmeldezeitraums',
'available_until' => 'Ende des Anmeldezeitraums',
'booking_option_id' => 'Anmeldeoption',
'city' => 'Stadt',
'comment' => 'Kommentar',
'country' => 'Land',
'current_password' => 'Derzeitiges Passwort',
'date' => 'Datum',
'date_from' => 'Beginn des Zeitraums',
Expand All @@ -171,17 +176,21 @@
'day' => 'Tag',
'description' => 'Beschreibung',
'email' => 'E-Mail-Adresse',
'event_series_id' => 'Teil der Veranstaltungsreihe',
'event_series_type' => 'Art der Veranstaltungsreihe',
'event_type' => 'Art der Veranstaltung',
'expires_at' => 'Ablaufdatum',
'file' => 'Datei',
'file_type' => 'Dateiformat',
'file' => 'Datei',
'finished_at' => 'Enddatum',
'first_name' => 'Vorname',
'groups_count' => 'Anzahl der Gruppen',
'height' => 'Höhe',
'hour' => 'Stunde',
'house_number' => 'Hausnummer',
'last_name' => 'Nachname',
'location_id' => 'Standort',
'maximum_bookings' => 'Maximale Anmeldungen',
'method' => 'Methode',
'minute' => 'Minute',
'month' => 'Monat',
Expand All @@ -194,21 +203,27 @@
'password' => 'Passwort',
'password_confirmation' => 'Passwort Bestätigung',
'phone' => 'Telefonnummer',
'postal_code' => 'Postleitzahl',
'price' => 'Preis',
'register_entry' => 'Registereintrag',
'representatives' => 'Vertreter',
'restrictions' => 'Einschränkungen',
'search' => 'Suchbegriff',
'second' => 'Sekunde',
'size' => 'Größe',
'slug' => 'Slug',
'sort' => 'Sortierung',
'started_at' => 'Startdatum',
'status' => 'Status',
'street' => 'Straße',
'terms_and_conditions' => 'AGB',
'thickness' => 'Dicke',
'time' => 'Uhrzeit',
'title' => 'Titel',
'terms_and_conditions' => 'AGB',
'unit' => 'Einheit',
'user_role_id' => 'Benutzerrolle',
'visibility' => 'Sichtbarkeit',
'website_url' => 'Webauftritt',
'width' => 'Breite',
'year' => 'Jahr',
],
Expand Down
14 changes: 14 additions & 0 deletions lang/en/validation.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,23 @@
* As the database scheme is in English, translations work out of the box for the most attributes.
* The other attributes have to be added here.
*/
'available_from' => 'Start of the booking period',
'available_until' => 'End of the booking period',
'booking_option_id' => 'Booking option',
'date_from' => 'start of the period',
'date_until' => 'end of the period',
'event_series_id' => 'Part of the event series',
'expires_at' => 'expiration date',
'finished_at' => 'End date',
'location_id' => 'Location',
'organization_id' => 'Organization',
'parent_event_id' => 'Part of the event',
'parent_event_series_id' => 'Part of the event series',
'parent_organization_id' => 'Parent organization',
'search' => 'search term',
'started_at' => 'Start date',
'user_role_id' => 'User role',
'website_url' => 'website',
],

];
4 changes: 2 additions & 2 deletions resources/views/booking_options/booking_option_form.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@
@endisset
</x-bs::form.field>
<x-bs::form.field name="available_from" type="datetime-local"
:value="isset($bookingOption->available_from) ? $bookingOption->available_from->format('Y-m-d\TH:i') : null">{{ __('Start date') }}</x-bs::form.field>
:value="isset($bookingOption->available_from) ? $bookingOption->available_from->format('Y-m-d\TH:i') : null">{{ __('Start of the booking period') }}</x-bs::form.field>
<x-bs::form.field name="available_until" type="datetime-local"
:value="isset($bookingOption->available_until) ? $bookingOption->available_until->format('Y-m-d\TH:i') : null">{{ __('End date') }}</x-bs::form.field>
:value="isset($bookingOption->available_until) ? $bookingOption->available_until->format('Y-m-d\TH:i') : null">{{ __('End of the booking period') }}</x-bs::form.field>
<x-bs::form.field name="price" type="number" min="0.01" step="0.01"
:value="$bookingOption->price ?? null">
{{ __('Price') }}
Expand Down