-
-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extended the channels model with domain, billing, etc data
- Loading branch information
1 parent
3558e8c
commit 8468ea0
Showing
6 changed files
with
174 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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 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 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
85 changes: 85 additions & 0 deletions
85
src/Channel/resources/database/migrations/2024_01_26_103355_extend_channels_table.php
This file contains 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,85 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class () extends Migration { | ||
public function up(): void | ||
{ | ||
Schema::table('channels', function (Blueprint $table) { | ||
$table->char('language', 2)->default('en')->comment('The two letter ISO 639-1 language code'); | ||
$table->string('domain', 255)->nullable()->unique(); | ||
$table->string('billing_company', 255)->nullable(); | ||
$table->char('billing_country_id', 2)->nullable(); | ||
$table->integer('billing_province_id')->unsigned()->nullable(); | ||
$table->string('billing_postalcode', 12)->nullable(); | ||
$table->string('billing_city')->nullable(); | ||
$table->string('billing_address', 384)->nullable(); | ||
$table->string('billing_address2', 255)->nullable(); | ||
$table->string('billing_tax_nr', 17)->nullable(); | ||
$table->string('billing_registration_nr')->nullable(); | ||
$table->string('email')->nullable(); | ||
$table->string('phone', 22)->nullable(); | ||
$table->json('billing_countries')->nullable(); | ||
$table->json('shipping_countries')->nullable(); | ||
$table->char('color', 7)->default('#777777'); | ||
$table->string('theme')->nullable(); | ||
}); | ||
} | ||
|
||
public function down(): void | ||
{ | ||
Schema::table('channels', function (Blueprint $table) { | ||
$table->dropColumn('language'); | ||
}); | ||
Schema::table('channels', function (Blueprint $table) { | ||
$table->dropColumn('domain'); | ||
}); | ||
Schema::table('channels', function (Blueprint $table) { | ||
$table->dropColumn('billing_company'); | ||
}); | ||
Schema::table('channels', function (Blueprint $table) { | ||
$table->dropColumn('billing_country_id'); | ||
}); | ||
Schema::table('channels', function (Blueprint $table) { | ||
$table->dropColumn('billing_province_id'); | ||
}); | ||
Schema::table('channels', function (Blueprint $table) { | ||
$table->dropColumn('billing_postalcode'); | ||
}); | ||
Schema::table('channels', function (Blueprint $table) { | ||
$table->dropColumn('billing_city'); | ||
}); | ||
Schema::table('channels', function (Blueprint $table) { | ||
$table->dropColumn('billing_address'); | ||
}); | ||
Schema::table('channels', function (Blueprint $table) { | ||
$table->dropColumn('billing_address2'); | ||
}); | ||
Schema::table('channels', function (Blueprint $table) { | ||
$table->dropColumn('billing_tax_nr'); | ||
}); | ||
Schema::table('channels', function (Blueprint $table) { | ||
$table->dropColumn('billing_registration_nr'); | ||
}); | ||
Schema::table('channels', function (Blueprint $table) { | ||
$table->dropColumn('email'); | ||
}); | ||
Schema::table('channels', function (Blueprint $table) { | ||
$table->dropColumn('phone'); | ||
}); | ||
Schema::table('channels', function (Blueprint $table) { | ||
$table->dropColumn('billing_countries'); | ||
}); | ||
Schema::table('channels', function (Blueprint $table) { | ||
$table->dropColumn('shipping_countries'); | ||
}); | ||
Schema::table('channels', function (Blueprint $table) { | ||
$table->dropColumn('color'); | ||
}); | ||
Schema::table('channels', function (Blueprint $table) { | ||
$table->dropColumn('theme'); | ||
}); | ||
} | ||
}; |
This file contains 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 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,34 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* Contains the ExtendedChannelTest class. | ||
* | ||
* @copyright Copyright (c) 2024 Vanilo UG | ||
* @author Attila Fulop | ||
* @license MIT | ||
* @since 2024-01-26 | ||
* | ||
*/ | ||
|
||
|
||
use Konekt\Address\Models\Country; | ||
use Vanilo\Foundation\Models\Channel; | ||
use Vanilo\Foundation\Tests\TestCase; | ||
|
||
class ExtendedChannelTest extends TestCase | ||
{ | ||
/** @test */ | ||
public function it_can_retrieve_the_billing_country() | ||
{ | ||
Country::create(['id' => 'DE', 'name' => 'Germany', 'phonecode' => 49, 'is_eu_member' => true]); | ||
|
||
$channel = Channel::create([ | ||
'name' => 'Test 50', | ||
'billing_country_id' => 'DE', | ||
]); | ||
|
||
$this->assertInstanceOf(Country::class, $channel->billingCountry); | ||
} | ||
} |