-
-
Notifications
You must be signed in to change notification settings - Fork 2
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
add phone area data migration #82
Conversation
PhoneArea::query()->insertOrIgnore([ | ||
[ | ||
'code' => 239, | ||
'state_id' => 1, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't use an ID for State (#16). We have to look it up as we did with Country in the States migration to add the data:
This is because the State ID could be different in the application.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure no problem. I'll change it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
->map(function (array $record) use ($now) { | ||
$stateId = State::fromAbbreviation($record['state_abbreviation'])->getId(); | ||
unset($record['state_abbreviation']); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a slick implementation!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
public static function fromAbbreviation(string $abbreviation): self | ||
{ | ||
/** @var State $result */ | ||
$result = static::query()->where('abbreviation', '=', $abbreviation)->firstOrFail(); | ||
|
||
return $result; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great! 🤩
@arwaawan3 Could you try breaking this out into 2 separate migrations and see if those last tests pass? |
Windows servers must have a limit on how many data rows can be added in a migration. |
Oh ok I will split it. |
@drewroberts I've split them in two files but I don't like the names of the two classes. If you any suggestions we can change them? |
I think it's great for right now. I'm going to end up moving these files later from |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! 🐐
Ok 👍 |
Closes #113 |
Closes #76