Skip to content

Commit

Permalink
Add "newsletter agreement" to user profile and admin
Browse files Browse the repository at this point in the history
  • Loading branch information
danon committed Sep 20, 2023
1 parent baf3820 commit 799792a
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 10 deletions.
5 changes: 5 additions & 0 deletions app/Domain/User/UserSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ public function marketingAgreement(): Html
konta albo poprzez wysłanie stosownej wiadomości na adres e-mail: $gdpr lub adres siedziby $_4programmers.");
}

public function newsletterAgreement(): Html
{
return new Html('Zgadzam się na otrzymywanie newslettera.');
}

public function termsAndPrivacyPolicyAgreement(): Html
{
$terms = '<a href="/Regulamin">regulamin</a>';
Expand Down
11 changes: 6 additions & 5 deletions app/Http/Controllers/Auth/RegisterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,12 @@ public function signup(RegisterForm $form): RedirectResponse

$this->transaction(function () use ($request) {
$user = User::forceCreate([
'name' => $request->input('name'),
'email' => $request->input('email'),
'password' => bcrypt($request->input('password')),
'guest_id' => $request->session()->get('guest_id'),
'marketing_agreement' => $request->input('marketing_agreement')
'name' => $request->input('name'),
'email' => $request->input('email'),
'password' => bcrypt($request->input('password')),
'guest_id' => $request->session()->get('guest_id'),
'marketing_agreement' => $request->input('marketing_agreement'),
'newsletter_agreement' => true
]);

app(MailQueue::class)
Expand Down
4 changes: 4 additions & 0 deletions app/Http/Forms/User/SettingsForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ public function buildForm(): void
'rules' => 'boolean',
'label' => new TwigHtml((new UserSettings)->marketingAgreement())
])
->add('newsletter_agreement', 'checkbox', [
'rules' => 'boolean',
'label' => new TwigHtml((new UserSettings)->newsletterAgreement())
])
->add('firm', 'text', [
'rules' => 'nullable|string|max:100',
'label' => 'Nazwa firmy',
Expand Down
11 changes: 6 additions & 5 deletions app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
use Carbon\Carbon;
use Coyote\Models\Scopes\ExcludeBlocked;
use Coyote\Notifications\ResetPasswordNotification;
use Coyote\Services\Media\Photo;
use Coyote\Services\Media\Factory as MediaFactory;
use Coyote\Services\Media\Photo;
use Coyote\User\Relation;
use Illuminate\Auth\Authenticatable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Auth\Passwords\CanResetPassword;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Foundation\Auth\Access\Authorizable;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Foundation\Auth\Access\Authorizable;
use Illuminate\Notifications\RoutesNotifications;
use Laravel\Passport\HasApiTokens;
use NotificationChannels\WebPush\HasPushSubscriptions;
Expand All @@ -40,6 +40,7 @@
* @property int $allow_sig
* @property int $allow_sticky_header
* @property bool $marketing_agreement
* @property bool $newsletter_agreement
* @property int $birthyear
* @property int $reputation
* @property string $name
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class AddNewsletterAgreementToUsers extends Migration
{
public function up(): void
{
Schema::table('users', function (Blueprint $table) {
$table->boolean('newsletter_agreement')->default(false);
});
}

public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn('newsletter_agreement');
});
}
}
1 change: 1 addition & 0 deletions resources/views/adm/users/save.twig
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
{{ form_row(form.allow_subscribe) }}
{{ form_row(form.allow_sticky_header) }}
{{ form_row(form.marketing_agreement) }}
{{ form_row(form.newsletter_agreement) }}
{{ form_row(form.delete_photo) }}
{{ form_row(form.firm) }}
{{ form_row(form.position) }}
Expand Down
1 change: 1 addition & 0 deletions resources/views/user/settings.twig
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<div class="card-body">
{{ form_row(form.terms) }}
{{ form_row(form.marketing_agreement) }}
{{ form_row(form.newsletter_agreement) }}

{{ form_row(form.submit) }}
</div>
Expand Down

0 comments on commit 799792a

Please sign in to comment.