Skip to content

Commit 3bff67f

Browse files
authored
Merge pull request #49 from tipoff/chx2/feature/46-email-address
Update Email address relationship #46
2 parents 1bec514 + 2ef7022 commit 3bff67f

File tree

7 files changed

+15
-102
lines changed

7 files changed

+15
-102
lines changed

database/factories/ContactFactory.php

+8-8
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ class ContactFactory extends Factory
1515
public function definition()
1616
{
1717
return [
18-
'form_type' => $this->faker->randomElement(FormType::getValues()),
19-
'location_id' => randomOrCreate(app('location')),
20-
'email' => $this->faker->email,
21-
'first_name' => $this->faker->firstName,
22-
'last_name' => $this->faker->lastName,
23-
'phone' => '555-555-5555',
24-
'company_name' => $this->faker->company,
25-
'message' => $this->faker->paragraph,
18+
'form_type' => $this->faker->randomElement(FormType::getValues()),
19+
'location_id' => randomOrCreate(app('location')),
20+
'email_address_id' => randomOrCreate(app('email_address')),
21+
'first_name' => $this->faker->firstName,
22+
'last_name' => $this->faker->lastName,
23+
'phone' => '555-555-5555',
24+
'company_name' => $this->faker->company,
25+
'message' => $this->faker->paragraph,
2626
];
2727
}
2828
}

database/migrations/2020_05_20_100000_create_contacts_table.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public function up()
1515
$table->string('form_type')->index();
1616
$table->string('reference_number')->index()->unique(); // Generated by system. This is identifier used to communicate with customer about their contact form. Reference number is emailed to them.
1717
$table->foreignIdFor(app('location'))->index();
18-
$table->string('email');
18+
$table->foreignIdFor(app('email_address'))->index();
1919
$table->foreignIdFor(app('user'))->nullable()->index();
2020
$table->string('first_name')->nullable();
2121
$table->string('last_name')->nullable();

src/Commands/AttachContactUsers.php

-52
This file was deleted.

src/FormsServiceProvider.php

-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
namespace Tipoff\Forms;
66

7-
use Tipoff\Forms\Commands\AttachContactUsers;
87
use Tipoff\Forms\Models\Contact;
98
use Tipoff\Forms\Models\ContactResponse;
109
use Tipoff\Forms\Policies\ContactPolicy;
@@ -25,9 +24,6 @@ public function configureTipoffPackage(TipoffPackage $package): void
2524
\Tipoff\Forms\Nova\Contact::class,
2625
\Tipoff\Forms\Nova\ContactResponse::class,
2726
])
28-
->hasCommands([
29-
AttachContactUsers::class,
30-
])
3127
->name('forms')
3228
->hasConfigFile();
3329
}

src/Models/Contact.php

+5
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ public function getContactStatusHistory(): Collection
7777
return $this->getStatusHistory(ContactStatus::statusType());
7878
}
7979

80+
public function email()
81+
{
82+
return $this->hasOne(app('email_address'));
83+
}
84+
8085
public function response()
8186
{
8287
return $this->hasOne(ContactResponse::class);

src/Nova/Contact.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
use Dniccum\PhoneNumber\PhoneNumber;
88
use Illuminate\Http\Request;
9-
use Inspheric\Fields\Email;
109
use Laravel\Nova\Fields\BelongsTo;
1110
use Laravel\Nova\Fields\Date;
1211
use Laravel\Nova\Fields\DateTime;
@@ -71,7 +70,7 @@ public function fields(Request $request)
7170
nova('location') ? BelongsTo::make('Location', 'location', nova('location'))->required()->hideWhenUpdating() : null,
7271
nova('user') ? BelongsTo::make('User', 'user', nova('user'))->required()->hideWhenUpdating() : null,
7372
PhoneNumber::make('Phone')->format('###-###-####')->disableValidation()->useMaskPlaceholder()->linkOnDetail()->hideWhenUpdating(),
74-
Email::make('Email', 'user.email')->clickable()->hideWhenUpdating(),
73+
nova('email_address') ? BelongsTo::make('Email Address', 'email_address', nova('email_address'))->sortable() : null,
7574
Textarea::make('Message')->rows(3)->alwaysShow()->nullable()->hideWhenUpdating(),
7675

7776
new Panel('Submission Details', $this->submissionFields()),

tests/Unit/Commands/AttachContactUsersCommandTest.php

-35
This file was deleted.

0 commit comments

Comments
 (0)