This repository has been archived by the owner on Apr 3, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9144f5e
commit 9f8fede
Showing
8 changed files
with
149 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php namespace Bedard\Shop\Models; | ||
|
||
use Model; | ||
|
||
/** | ||
* Address Model | ||
*/ | ||
class Address extends Model | ||
{ | ||
use \October\Rain\Database\Traits\Validation; | ||
|
||
/** | ||
* @var string The database table used by the model. | ||
*/ | ||
public $table = 'bedard_shop_addresses'; | ||
|
||
/** | ||
* @var array Default attributes | ||
*/ | ||
public $attributes = [ | ||
'country' => null, | ||
'locality' => null, | ||
'postal_code' => null, | ||
'region' => null, | ||
'street' => '[]', | ||
]; | ||
|
||
/** | ||
* @var array Fillable fields | ||
*/ | ||
protected $fillable = [ | ||
'country_code', | ||
'locality', | ||
'postal_code', | ||
'region', | ||
'street', | ||
]; | ||
|
||
/** | ||
* @var array Guarded fields | ||
*/ | ||
protected $guarded = ['*']; | ||
|
||
/** | ||
* @var array Jsonable fields | ||
*/ | ||
protected $jsonable = [ | ||
'street', | ||
]; | ||
|
||
/** | ||
* @var array Relations | ||
*/ | ||
public $belongsToMany = []; | ||
|
||
/** | ||
* @var array Validation | ||
*/ | ||
public $rules = [ | ||
'street' => 'array', | ||
]; | ||
} |
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,8 @@ | ||
# =================================== | ||
# List Column Definitions | ||
# =================================== | ||
|
||
columns: | ||
id: | ||
label: ID | ||
searchable: true |
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,8 @@ | ||
# =================================== | ||
# Form Field Definitions | ||
# =================================== | ||
|
||
fields: | ||
id: | ||
label: ID | ||
disabled: true |
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,28 @@ | ||
<?php namespace Bedard\Shop\Tests\Unit\Models; | ||
|
||
use Bedard\Shop\Classes\Factory; | ||
use Bedard\Shop\Models\Address; | ||
use Bedard\Shop\Tests\Unit\ShopTestCase; | ||
|
||
class AddressTest extends ShopTestCase | ||
{ | ||
public function test_initial_street_value_is_an_empty_array() | ||
{ | ||
$address = new Address; | ||
$this->assertTrue(is_array($address->street)); | ||
$this->assertEquals(0, count($address->street)); | ||
} | ||
|
||
public function test_saving_multiple_street_lines() | ||
{ | ||
$address = Factory::create(new Address, [ | ||
'street' => [ | ||
'123 Foo St.', | ||
'Apartment #1234', | ||
], | ||
]); | ||
|
||
$this->assertEquals('123 Foo St.', $address->street[0]); | ||
$this->assertEquals('Apartment #1234', $address->street[1]); | ||
} | ||
} |
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,27 @@ | ||
<?php namespace Bedard\Shop\Updates; | ||
|
||
use Schema; | ||
use October\Rain\Database\Schema\Blueprint; | ||
use October\Rain\Database\Updates\Migration; | ||
|
||
class CreateAddressesTable extends Migration | ||
{ | ||
public function up() | ||
{ | ||
Schema::create('bedard_shop_addresses', function(Blueprint $table) { | ||
$table->engine = 'InnoDB'; | ||
$table->increments('id'); | ||
$table->json('street')->nullable(); | ||
$table->string('locality')->nullable(); | ||
$table->string('region')->nullable(); | ||
$table->string('postal_code')->nullable(); | ||
$table->string('country_code', 2)->nullable(); | ||
$table->timestamps(); | ||
}); | ||
} | ||
|
||
public function down() | ||
{ | ||
Schema::dropIfExists('bedard_shop_addresses'); | ||
} | ||
} |
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