-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create timezone migration, model & factory #32
- Loading branch information
1 parent
1f53664
commit c70f4f7
Showing
3 changed files
with
74 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tipoff\Addresses\Database\Factories; | ||
|
||
use Illuminate\Database\Eloquent\Factories\Factory; | ||
use Tipoff\Addresses\Models\Timezone; | ||
|
||
class TimezoneFactory extends Factory | ||
{ | ||
protected $model = Timezone::class; | ||
|
||
public function definition() | ||
{ | ||
return [ | ||
'name' => $this->faker->timezone, | ||
'title' => $this->faker->timezone, | ||
'php' => $this->faker->timezone, | ||
'is_daylight_saving' => $this->faker->boolean | ||
]; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
database/migrations/2014_01_01_100000_create_timezones_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,22 @@ | ||
|
||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
class CreateTimezonesTable extends Migration | ||
{ | ||
public function up() | ||
{ | ||
Schema::create('timezones', function (Blueprint $table) { | ||
$table->id(); | ||
$table->string('name')->unique(); // Abbreviation | ||
$table->string('title')->unique(); | ||
$table->string('php')->unique(); // Supported PHP Timezone: https://www.php.net/manual/en/timezones.php | ||
$table->boolean('is_daylight_saving')->default(1); // Just for reference, Carbon has this. | ||
$table->decimal('dst', 4, 2)->nullable(); // Just for reference, Carbon has this. | ||
$table->decimal('standard', 4, 2)->nullable(); // Just for reference, Carbon has this. | ||
}); | ||
} | ||
} |
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,29 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tipoff\Addresses\Models; | ||
|
||
use Tipoff\Support\Models\BaseModel; | ||
use Tipoff\Support\Traits\HasCreator; | ||
use Tipoff\Support\Traits\HasPackageFactory; | ||
use Tipoff\Support\Traits\HasUpdater; | ||
|
||
class Timezone extends BaseModel | ||
{ | ||
use HasPackageFactory; | ||
use HasCreator; | ||
use HasUpdater; | ||
|
||
public $timestamps = false; | ||
|
||
public function markets() | ||
{ | ||
return $this->belongsToMany(app('market')); | ||
} | ||
|
||
public function locations() | ||
{ | ||
return $this->belongsToMany(app('location')); | ||
} | ||
} |