Skip to content

Commit

Permalink
Document item table quantity column length changes..
Browse files Browse the repository at this point in the history
  • Loading branch information
cuneytsenturk committed Aug 29, 2022
1 parent 568bf86 commit 9f172b9
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 4 deletions.
4 changes: 2 additions & 2 deletions app/Http/Requests/Document/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ public function rules()

if ($items) {
foreach ($items as $key => $item) {
$size = 5;
$size = 10;

if (Str::contains($item['quantity'], ['.', ','])) {
$size = 7;
$size = 12;
}

$rules['items.' . $key . '.quantity'] = 'required|max:' . $size;
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Requests/Document/DocumentItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class DocumentItem extends FormRequest
{
protected $quantity_size = 5;
protected $quantity_size = 10;

/**
* Get the validation rules that apply to the request.
Expand All @@ -17,7 +17,7 @@ class DocumentItem extends FormRequest
public function rules()
{
if (Str::contains($this->request->get('quantity'), ['.', ','])) {
$this->quantity_size = 7;
$this->quantity_size = 12;
}

return [
Expand Down
36 changes: 36 additions & 0 deletions database/migrations/2022_08_29_000000_core_v307.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

use Doctrine\DBAL\Types\FloatType;
use Doctrine\DBAL\Types\Type;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
if (! Type::hasType('double')) {
Type::addType('double', FloatType::class);
}

Schema::table('document_items', function(Blueprint $table) {
$table->double('quantity', 12, 2)->change();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
};

0 comments on commit 9f172b9

Please sign in to comment.