-
Notifications
You must be signed in to change notification settings - Fork 4
#10 user address book implementation #14
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
SlimDeluxe
merged 16 commits into
DataLinx:main
from
thapacodes4u:#10-user-address-book-implementation
Jul 18, 2025
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
7b3c664
refactor(tests): update middleware reference to SetupSite
thapacodes4u d582569
Merge branch 'main' of github.com:thapacodes4u/eclipsephp-core
thapacodes4u 8d62e33
feat: adding user address book
thapacodes4u 491ff21
fix: refactoring & adding new test cases
thapacodes4u 6cc582b
feat: refactoring & adding address book enable/disable feature
thapacodes4u daa5276
fix: bug fixes
thapacodes4u 686f4ba
fix: bug fixes
thapacodes4u 405ab95
Merge branch 'main' of github.com:DataLinx/eclipsephp-core into #10-u…
0debef1
fix: failing test
7b0a2fd
fix: error related to relation manager
d9838a3
fix: refactoring address observer
8f349f8
Merge branch 'main' into #10-user-address-book-implementation
thapacodes4u 12dfa48
Merge branch 'main' into fork/thapacodes4u/#10-user-address-book-impl…
SlimDeluxe 495461e
fix: default address assigning and removal
3f58365
Merge branch '#10-user-address-book-implementation' of github.com:tha…
e712f9a
fix: adding requested test cases
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| <?php | ||
|
|
||
| namespace Eclipse\Core\Database\Factories; | ||
|
|
||
| use Eclipse\Core\Enums\AddressType; | ||
| use Eclipse\Core\Models\User; | ||
| use Eclipse\Core\Models\User\Address; | ||
| use Eclipse\World\Models\Country; | ||
| use Illuminate\Database\Eloquent\Factories\Factory; | ||
|
|
||
| class AddressFactory extends Factory | ||
| { | ||
| /** | ||
| * The name of the factory's corresponding model. | ||
| * | ||
| * @var string | ||
| */ | ||
| protected $model = Address::class; | ||
|
|
||
| /** | ||
| * Define the model's default state. | ||
| * | ||
| * @return array<string, mixed> | ||
| */ | ||
| public function definition(): array | ||
| { | ||
| $type = match (fake()->numberBetween(1, 3)) { | ||
| 1 => [AddressType::COMPANY_ADDRESS->value], | ||
| 2 => [AddressType::DEFAULT_ADDRESS->value], | ||
| 3 => [AddressType::COMPANY_ADDRESS->value, AddressType::DEFAULT_ADDRESS->value], | ||
| }; | ||
|
|
||
| $hasCompanyAddress = in_array(AddressType::COMPANY_ADDRESS->value, $type); | ||
|
|
||
| return [ | ||
| 'recipient' => fake()->name(), | ||
| 'company_name' => $hasCompanyAddress ? fake()->company() : null, | ||
| 'company_vat_id' => $hasCompanyAddress ? fake()->numerify('##########') : null, | ||
| 'street_address' => [ | ||
| fake()->streetAddress(), | ||
| fake()->streetAddress(), | ||
| ], | ||
| 'postal_code' => fake()->postcode(), | ||
| 'city' => fake()->city(), | ||
| 'type' => $type, | ||
| 'country_id' => Country::inRandomOrder()->first()?->id ?? Country::factory()->create()->id, | ||
| 'user_id' => User::inRandomOrder()->first()?->id ?? User::factory()->create()->id, | ||
| ]; | ||
| } | ||
| } |
44 changes: 44 additions & 0 deletions
44
database/migrations/2025_06_16_150346_create_user_addresses_table.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| <?php | ||
|
|
||
| use Illuminate\Database\Migrations\Migration; | ||
| use Illuminate\Database\Schema\Blueprint; | ||
| use Illuminate\Support\Facades\Schema; | ||
|
|
||
| return new class extends Migration | ||
| { | ||
| /** | ||
| * Run the migrations. | ||
| */ | ||
| public function up(): void | ||
| { | ||
| Schema::create('user_addresses', function (Blueprint $table) { | ||
| $table->id(); | ||
| $table->string('recipient', 100); | ||
| $table->string('company_name', 100) | ||
| ->nullable(); | ||
| $table->string('company_vat_id', 50) | ||
| ->nullable(); | ||
| $table->json('street_address'); | ||
| $table->string('postal_code', 50); | ||
| $table->string('city', 100); | ||
| $table->json('type')->nullable(); | ||
| $table->string('country_id', 2); | ||
| $table->foreignId('user_id') | ||
| ->constrained('users') | ||
| ->cascadeOnDelete(); | ||
| $table->softDeletes(); | ||
| $table->timestamps(); | ||
| $table->foreign('country_id') | ||
| ->references('id') | ||
| ->on('world_countries'); | ||
| }); | ||
| } | ||
|
|
||
| /** | ||
| * Reverse the migrations. | ||
| */ | ||
| public function down(): void | ||
| { | ||
| Schema::dropIfExists('user_addresses'); | ||
| } | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| <?php | ||
|
|
||
| namespace Eclipse\Core\Enums; | ||
|
|
||
| use Filament\Support\Contracts\HasDescription; | ||
| use Filament\Support\Contracts\HasLabel; | ||
|
|
||
| enum AddressType: string implements HasDescription, HasLabel | ||
| { | ||
| case DEFAULT_ADDRESS = 'default_address'; | ||
| case COMPANY_ADDRESS = 'company_address'; | ||
|
|
||
| public function getLabel(): ?string | ||
| { | ||
| return match ($this) { | ||
| self::DEFAULT_ADDRESS => 'Default', | ||
| self::COMPANY_ADDRESS => 'Company' | ||
| }; | ||
| } | ||
|
|
||
| public function getDescription(): ?string | ||
| { | ||
| return match ($this) { | ||
| self::DEFAULT_ADDRESS => 'This is the default address', | ||
| self::COMPANY_ADDRESS => 'This is a company address' | ||
| }; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.