This repository was archived by the owner on Feb 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 106
Add Float to Entity Types #119
Closed
Closed
Changes from 2 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
a817b40
Add Float to Entity Types
flakerimi b2b4ccc
Update 2020_01_01_000005_create_attribute_float_values_table.php
flakerimi f43fd08
Update .codeclimate.yml
flakerimi f57748e
Update 2020_01_01_000005_create_attribute_float_values_table.php
flakerimi 4f94fde
Added Calculated Fields
flakerimi 9650bce
fixed typos
flakerimi 13be152
removed calculated field
flakerimi 83afc48
added calcualted as type
flakerimi 72ef625
add increment
flakerimi 33c69ce
Update 2020_01_01_000001_create_attributes_table.php
flakerimi 5a88e4d
Fatal error: Cannot use 'float' as class name as it is reserved
flakerimi 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
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
42 changes: 42 additions & 0 deletions
42
database/migrations/2020_01_01_000005_create_attribute_float_values_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,42 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Illuminate\Support\Facades\Schema; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Database\Migrations\Migration; | ||
|
||
class CreateAttributeFloadValuesTable extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function up(): void | ||
{ | ||
Schema::create(config('rinvex.attributes.tables.attribute_integer_values'), function (Blueprint $table) { | ||
// Columns | ||
$table->bigIncrements('id'); | ||
$table->float('content', 8, 2); | ||
$table->bigInteger('attribute_id')->unsigned(); | ||
$table->bigInteger('entity_id')->unsigned(); | ||
$table->string('entity_type'); | ||
$table->timestamps(); | ||
|
||
// Indexes | ||
$table->foreign('attribute_id')->references('id')->on(config('rinvex.attributes.tables.attributes')) | ||
->onDelete('cascade')->onUpdate('cascade'); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function down(): void | ||
{ | ||
Schema::dropIfExists(config('rinvex.attributes.tables.attribute_integer_values')); | ||
} | ||
} |
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,60 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rinvex\Attributes\Models\Type; | ||
|
||
use Rinvex\Attributes\Models\Value; | ||
|
||
/** | ||
* Rinvex\Attributes\Models\Type\Float. | ||
* | ||
* @property int $id | ||
* @property int $content | ||
* @property int $attribute_id | ||
* @property int $entity_id | ||
* @property string $entity_type | ||
* @property \Carbon\Carbon|null $created_at | ||
* @property \Carbon\Carbon|null $updated_at | ||
* @property-read \Rinvex\Attributes\Models\Attribute $attribute | ||
* @property-read \Illuminate\Database\Eloquent\Model|\Eloquent $entity | ||
* | ||
* @method static \Illuminate\Database\Eloquent\Builder|\Rinvex\Attributes\Models\Type\Float whereAttributeId($value) | ||
* @method static \Illuminate\Database\Eloquent\Builder|\Rinvex\Attributes\Models\Type\Float whereContent($value) | ||
* @method static \Illuminate\Database\Eloquent\Builder|\Rinvex\Attributes\Models\Type\Float whereCreatedAt($value) | ||
* @method static \Illuminate\Database\Eloquent\Builder|\Rinvex\Attributes\Models\Type\Float whereEntityId($value) | ||
* @method static \Illuminate\Database\Eloquent\Builder|\Rinvex\Attributes\Models\Type\Float whereEntityType($value) | ||
* @method static \Illuminate\Database\Eloquent\Builder|\Rinvex\Attributes\Models\Type\Float whereId($value) | ||
* @method static \Illuminate\Database\Eloquent\Builder|\Rinvex\Attributes\Models\Type\Float whereUpdatedAt($value) | ||
* @mixin \Eloquent | ||
*/ | ||
class Float extends Value | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected $casts = [ | ||
'content' => 'float', | ||
'attribute_id' => 'float', | ||
'entity_id' => 'float', | ||
'entity_type' => 'string', | ||
]; | ||
|
||
/** | ||
* Create a new Eloquent model instance. | ||
* | ||
* @param array $attributes | ||
*/ | ||
public function __construct(array $attributes = []) | ||
{ | ||
parent::__construct($attributes); | ||
|
||
$this->setTable(config('rinvex.attributes.tables.attribute_float_values')); | ||
$this->setRules([ | ||
'content' => 'required|regex:/^\d*(\.\d{2})?$/', | ||
'attribute_id' => 'required|integer|exists:'.config('rinvex.attributes.tables.attributes').',id', | ||
'entity_id' => 'required|integer', | ||
'entity_type' => 'required|string', | ||
]); | ||
} | ||
} |
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
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.