Skip to content
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

Update Email address relationship #46 #49

Merged
merged 4 commits into from
Mar 24, 2021
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
16 changes: 8 additions & 8 deletions database/factories/ContactFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ class ContactFactory extends Factory
public function definition()
{
return [
'form_type' => $this->faker->randomElement(FormType::getValues()),
'location_id' => randomOrCreate(app('location')),
'email' => $this->faker->email,
'first_name' => $this->faker->firstName,
'last_name' => $this->faker->lastName,
'phone' => '555-555-5555',
'company_name' => $this->faker->company,
'message' => $this->faker->paragraph,
'form_type' => $this->faker->randomElement(FormType::getValues()),
'location_id' => randomOrCreate(app('location')),
'email_address_id' => randomOrCreate(app('email_address')),
'first_name' => $this->faker->firstName,
'last_name' => $this->faker->lastName,
'phone' => '555-555-5555',
'company_name' => $this->faker->company,
'message' => $this->faker->paragraph,
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function up()
$table->string('form_type')->index();
$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.
$table->foreignIdFor(app('location'))->index();
$table->string('email');
$table->foreignIdFor(app('email_address'))->index();
$table->foreignIdFor(app('user'))->nullable()->index();
$table->string('first_name')->nullable();
$table->string('last_name')->nullable();
Expand Down
52 changes: 0 additions & 52 deletions src/Commands/AttachContactUsers.php

This file was deleted.

4 changes: 0 additions & 4 deletions src/FormsServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace Tipoff\Forms;

use Tipoff\Forms\Commands\AttachContactUsers;
use Tipoff\Forms\Models\Contact;
use Tipoff\Forms\Models\ContactResponse;
use Tipoff\Forms\Policies\ContactPolicy;
Expand All @@ -25,9 +24,6 @@ public function configureTipoffPackage(TipoffPackage $package): void
\Tipoff\Forms\Nova\Contact::class,
\Tipoff\Forms\Nova\ContactResponse::class,
])
->hasCommands([
AttachContactUsers::class,
])
->name('forms')
->hasConfigFile();
}
Expand Down
5 changes: 5 additions & 0 deletions src/Models/Contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ public function getContactStatusHistory(): Collection
return $this->getStatusHistory(ContactStatus::statusType());
}

public function email()
{
return $this->hasOne(app('email_address'));
}

public function response()
{
return $this->hasOne(ContactResponse::class);
Expand Down
3 changes: 1 addition & 2 deletions src/Nova/Contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

use Dniccum\PhoneNumber\PhoneNumber;
use Illuminate\Http\Request;
use Inspheric\Fields\Email;
use Laravel\Nova\Fields\BelongsTo;
use Laravel\Nova\Fields\Date;
use Laravel\Nova\Fields\DateTime;
Expand Down Expand Up @@ -71,7 +70,7 @@ public function fields(Request $request)
nova('location') ? BelongsTo::make('Location', 'location', nova('location'))->required()->hideWhenUpdating() : null,
nova('user') ? BelongsTo::make('User', 'user', nova('user'))->required()->hideWhenUpdating() : null,
PhoneNumber::make('Phone')->format('###-###-####')->disableValidation()->useMaskPlaceholder()->linkOnDetail()->hideWhenUpdating(),
Email::make('Email', 'user.email')->clickable()->hideWhenUpdating(),
nova('email_address') ? BelongsTo::make('Email Address', 'email_address', nova('email_address'))->sortable() : null,
Textarea::make('Message')->rows(3)->alwaysShow()->nullable()->hideWhenUpdating(),

new Panel('Submission Details', $this->submissionFields()),
Expand Down
35 changes: 0 additions & 35 deletions tests/Unit/Commands/AttachContactUsersCommandTest.php

This file was deleted.