Test Setup Failed
Push — master ( 68873d...747ad0 )
by Ron
05:19
created
database/factories/ProductFactory.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -11,38 +11,38 @@
 block discarded – undo
11 11
 use Illuminate\Support\Str;
12 12
 use Faker\Generator as Faker;
13 13
 
14
-$factory->define(Product::class, function (Faker $faker) {
14
+$factory->define(Product::class, function(Faker $faker) {
15 15
 	return [
16 16
 		'category_id' => factory(Category::class)->create()->id,
17
-		'name' => $faker->words(rand(1,3), true),
17
+		'name' => $faker->words(rand(1, 3), true),
18 18
 		'short_description' => $faker->sentences(5, true),
19 19
 		'description' => $faker->sentences(10, true),
20 20
 		'is_active' => true
21 21
 	];
22 22
 });
23 23
 
24
-$factory->define(Attribute::class, function (Faker $faker) {
24
+$factory->define(Attribute::class, function(Faker $faker) {
25 25
 	return [
26 26
 		'product_id' => null, // it should be attach manually
27 27
 		'name' => $faker->word
28 28
 	];
29 29
 });
30 30
 
31
-$factory->define(AttributeValue::class, function (Faker $faker) {
31
+$factory->define(AttributeValue::class, function(Faker $faker) {
32 32
 	return [
33 33
 		'product_attribute_id' => null, // it should be attach manually
34 34
 		'value' => $faker->word
35 35
 	];
36 36
 });
37 37
 
38
-$factory->define(ProductSku::class, function (Faker $faker) {
38
+$factory->define(ProductSku::class, function(Faker $faker) {
39 39
 	return [
40 40
 		'product_id' => null, // it should be manually added
41 41
 		'code' => Str::random()
42 42
 	];
43 43
 });
44 44
 
45
-$factory->define(ProductVariant::class, function (Faker $faker) {
45
+$factory->define(ProductVariant::class, function(Faker $faker) {
46 46
 	return [
47 47
 		'product_id' => null, // it should be manually added
48 48
 		'product_sku_id' => null, // it should be manually added
Please login to merge, or discard this patch.
database/factories/WarehouseFactory.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@
 block discarded – undo
3 3
 use Ronmrcdo\Inventory\Models\Warehouse;
4 4
 use Faker\Generator as Faker;
5 5
 
6
-$factory->define(Warehouse::class, function (Faker $faker) {
6
+$factory->define(Warehouse::class, function(Faker $faker) {
7 7
 	return [
8 8
 		'name' => $faker->word,
9 9
 		'description' => $faker->words(3, true)
Please login to merge, or discard this patch.
src/Resources/ProductResource.php 1 patch
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -8,32 +8,32 @@
 block discarded – undo
8 8
 
9 9
 class ProductResource extends JsonResource
10 10
 {
11
-    /**
12
-     * Transform the resource into an array.
13
-     *
14
-     * @param  \Illuminate\Http\Request  $request
15
-     * @return array
16
-     */
17
-    public function toArray($request)
18
-    {
19
-        return [
20
-            'id' => $this->id,
11
+	/**
12
+	 * Transform the resource into an array.
13
+	 *
14
+	 * @param  \Illuminate\Http\Request  $request
15
+	 * @return array
16
+	 */
17
+	public function toArray($request)
18
+	{
19
+		return [
20
+			'id' => $this->id,
21 21
 			'name' => $this->name,
22
-            'slug' => $this->slug,
23
-            'sku' => $this->hasSku() ? $this->skus()->first()->code : null,
22
+			'slug' => $this->slug,
23
+			'sku' => $this->hasSku() ? $this->skus()->first()->code : null,
24 24
 			'short_description' => $this->short_description,
25
-            'description' => $this->description,
26
-            'price' => $this->hasSku() ? $this->skus()->first()->price : 0.00,
27
-            'cost' => $this->hasSku() ? $this->skus()->first()->price : 0.00,
28
-            'is_active' => $this->is_active,
29
-            'category' => [
30
-                'id' => $this->category->id,
31
-                'name' => $this->category->name
32
-            ],
33
-            'attributes' => AttributeResource::collection($this->attributes)->toArray(app('request')),
34
-            'variations' => $this->when($this->hasAttributes() && $this->hasSku(), 
35
-                VariantResource::collection($this->skus)->toArray(app('request'))
36
-            )
37
-        ];
38
-    }
25
+			'description' => $this->description,
26
+			'price' => $this->hasSku() ? $this->skus()->first()->price : 0.00,
27
+			'cost' => $this->hasSku() ? $this->skus()->first()->price : 0.00,
28
+			'is_active' => $this->is_active,
29
+			'category' => [
30
+				'id' => $this->category->id,
31
+				'name' => $this->category->name
32
+			],
33
+			'attributes' => AttributeResource::collection($this->attributes)->toArray(app('request')),
34
+			'variations' => $this->when($this->hasAttributes() && $this->hasSku(), 
35
+				VariantResource::collection($this->skus)->toArray(app('request'))
36
+			)
37
+		];
38
+	}
39 39
 }
40 40
\ No newline at end of file
Please login to merge, or discard this patch.
src/Resources/AttributeResource.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
 		return [
12 12
 			'id' => $this->id,
13 13
 			'name' => $this->name,
14
-			'options' => collect($this->values)->map(function ($item) {
14
+			'options' => collect($this->values)->map(function($item) {
15 15
 				return $item->value;
16 16
 			})->values()->toArray()
17 17
 		];
Please login to merge, or discard this patch.
src/Resources/VariantResource.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@
 block discarded – undo
21 21
 				'id' => $this->product->category_id,
22 22
 				'name' => $this->product->category->name
23 23
 			],
24
-			'attributes' => collect($this->variant)->map(function ($item) {
24
+			'attributes' => collect($this->variant)->map(function($item) {
25 25
 				return [
26 26
 					'name' => $item->attribute->name,
27 27
 					'option' => $item->option->value
Please login to merge, or discard this patch.
src/ProductServiceProvider.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -14,20 +14,20 @@  discard block
 block discarded – undo
14 14
 	public function boot(): void
15 15
 	{
16 16
 		// Publishing is only necessary when using the CLI.
17
-        if ($this->app->runningInConsole()) {
18
-            $this->bootForConsole();
19
-        }
17
+		if ($this->app->runningInConsole()) {
18
+			$this->bootForConsole();
19
+		}
20 20
 	}
21 21
 
22 22
 	/**
23
-     * Get the services provided by the provider.
24
-     *
25
-     * @return array
26
-     */
27
-    public function provides()
28
-    {
29
-        return ['inventory'];
30
-    }
23
+	 * Get the services provided by the provider.
24
+	 *
25
+	 * @return array
26
+	 */
27
+	public function provides()
28
+	{
29
+		return ['inventory'];
30
+	}
31 31
 
32 32
 	/**
33 33
 	 * Register the bootable configurations
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 		$this->loadMigrationsFrom(__DIR__.'/../database/migrations');
40 40
 
41 41
 		$this->publishes([
42
-            __DIR__.'/../database/migrations' => database_path('migrations')
43
-        ], 'inventory.migrations');
42
+			__DIR__.'/../database/migrations' => database_path('migrations')
43
+		], 'inventory.migrations');
44 44
 	}
45 45
 }
46 46
\ No newline at end of file
Please login to merge, or discard this patch.
src/Models/InventoryStock.php 2 patches
Indentation   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -10,89 +10,89 @@
 block discarded – undo
10 10
 
11 11
 class InventoryStock extends Model
12 12
 {
13
-    use HasItemStocks;
13
+	use HasItemStocks;
14 14
 
15
-    /**
16
-     * Table name
17
-     * 
18
-     * @var string
19
-     */
20
-    protected $table = 'inventory_stocks';
15
+	/**
16
+	 * Table name
17
+	 * 
18
+	 * @var string
19
+	 */
20
+	protected $table = 'inventory_stocks';
21 21
 
22
-    /**
23
-     * Fields that can be mass assigned
24
-     * 
25
-     * @var array
26
-     */
27
-    protected $fillable = [
28
-        'warehouse_id', 'product_sku_id', 'quantity',
29
-        'aisle', 'row'
30
-    ];
22
+	/**
23
+	 * Fields that can be mass assigned
24
+	 * 
25
+	 * @var array
26
+	 */
27
+	protected $fillable = [
28
+		'warehouse_id', 'product_sku_id', 'quantity',
29
+		'aisle', 'row'
30
+	];
31 31
 
32
-    /**
33
-     * Guarded fields from mass assign
34
-     * 
35
-     * @var array
36
-     */
37
-    protected $guarded = [
38
-        'id', 'created_at', 'updated_at'
39
-    ];
32
+	/**
33
+	 * Guarded fields from mass assign
34
+	 * 
35
+	 * @var array
36
+	 */
37
+	protected $guarded = [
38
+		'id', 'created_at', 'updated_at'
39
+	];
40 40
 
41
-    /**
42
-     * Local Scope to find item by sku on the inventory
43
-     * 
44
-     * @param \Illuminate\Database\Eloquent\Builder $query
45
-     * @param string $sku
46
-     * @return \Illuminate\Database\Eloquent\Builder
47
-     */
48
-    public function scopeFindItemBySku(Builder $query, string $sku): Builder
49
-    {
50
-        return $query->whereHas('product.code', function ($q) use ($sku) {
51
-            $q->where('code', 'LIKE', '%'. $sku .'%');
52
-        });
53
-    }
41
+	/**
42
+	 * Local Scope to find item by sku on the inventory
43
+	 * 
44
+	 * @param \Illuminate\Database\Eloquent\Builder $query
45
+	 * @param string $sku
46
+	 * @return \Illuminate\Database\Eloquent\Builder
47
+	 */
48
+	public function scopeFindItemBySku(Builder $query, string $sku): Builder
49
+	{
50
+		return $query->whereHas('product.code', function ($q) use ($sku) {
51
+			$q->where('code', 'LIKE', '%'. $sku .'%');
52
+		});
53
+	}
54 54
 
55
-    /**
56
-     * Local scope to find an item based on product name
57
-     * 
58
-     * @param \Illuminate\Database\Eloquent\Builder $query
59
-     * @param string $sku
60
-     * @return \Illuminate\Database\Eloquent\Builder
61
-     */
62
-    public function scopeFindItem(Builder $query, string $product): Builder
63
-    {
64
-        return $query->whereHas('product.product', function ($q) use ($product) {
65
-            return $q->where('name', 'LIKE', '%'. $product .'%');
66
-        });
67
-    }
55
+	/**
56
+	 * Local scope to find an item based on product name
57
+	 * 
58
+	 * @param \Illuminate\Database\Eloquent\Builder $query
59
+	 * @param string $sku
60
+	 * @return \Illuminate\Database\Eloquent\Builder
61
+	 */
62
+	public function scopeFindItem(Builder $query, string $product): Builder
63
+	{
64
+		return $query->whereHas('product.product', function ($q) use ($product) {
65
+			return $q->where('name', 'LIKE', '%'. $product .'%');
66
+		});
67
+	}
68 68
 
69
-    /**
70
-     * Relation to the warehouse
71
-     * 
72
-     * @return \lluminate\Database\Eloquent\Relations\BelongsTo
73
-     */
74
-    public function warehouse(): BelongsTo
75
-    {
76
-        return $this->belongsTo('Ronmrcdo\Inventory\Models\Warehouse');
77
-    }
69
+	/**
70
+	 * Relation to the warehouse
71
+	 * 
72
+	 * @return \lluminate\Database\Eloquent\Relations\BelongsTo
73
+	 */
74
+	public function warehouse(): BelongsTo
75
+	{
76
+		return $this->belongsTo('Ronmrcdo\Inventory\Models\Warehouse');
77
+	}
78 78
 
79
-    /**
80
-     * Relation to the product
81
-     * 
82
-     * @return \lluminate\Database\Eloquent\Relations\BelongsTo
83
-     */
84
-    public function product(): BelongsTo
85
-    {
86
-        return $this->belongsTo('Ronmrcdo\Inventory\Models\ProductSku' ,'product_sku_id');
87
-    }
79
+	/**
80
+	 * Relation to the product
81
+	 * 
82
+	 * @return \lluminate\Database\Eloquent\Relations\BelongsTo
83
+	 */
84
+	public function product(): BelongsTo
85
+	{
86
+		return $this->belongsTo('Ronmrcdo\Inventory\Models\ProductSku' ,'product_sku_id');
87
+	}
88 88
 
89
-    /**
90
-     * Relation to the stock Movements
91
-     * 
92
-     * @return \lluminate\Database\Eloquent\Relations\HasMany
93
-     */
94
-    public function movements(): HasMany
95
-    {
96
-        return $this->hasMany('Ronmrcdo\Inventory\Models\InventoryStockMovement', 'stock_id', 'id');
97
-    }
89
+	/**
90
+	 * Relation to the stock Movements
91
+	 * 
92
+	 * @return \lluminate\Database\Eloquent\Relations\HasMany
93
+	 */
94
+	public function movements(): HasMany
95
+	{
96
+		return $this->hasMany('Ronmrcdo\Inventory\Models\InventoryStockMovement', 'stock_id', 'id');
97
+	}
98 98
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -47,8 +47,8 @@  discard block
 block discarded – undo
47 47
      */
48 48
     public function scopeFindItemBySku(Builder $query, string $sku): Builder
49 49
     {
50
-        return $query->whereHas('product.code', function ($q) use ($sku) {
51
-            $q->where('code', 'LIKE', '%'. $sku .'%');
50
+        return $query->whereHas('product.code', function($q) use ($sku) {
51
+            $q->where('code', 'LIKE', '%'.$sku.'%');
52 52
         });
53 53
     }
54 54
 
@@ -61,8 +61,8 @@  discard block
 block discarded – undo
61 61
      */
62 62
     public function scopeFindItem(Builder $query, string $product): Builder
63 63
     {
64
-        return $query->whereHas('product.product', function ($q) use ($product) {
65
-            return $q->where('name', 'LIKE', '%'. $product .'%');
64
+        return $query->whereHas('product.product', function($q) use ($product) {
65
+            return $q->where('name', 'LIKE', '%'.$product.'%');
66 66
         });
67 67
     }
68 68
 
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
      */
84 84
     public function product(): BelongsTo
85 85
     {
86
-        return $this->belongsTo('Ronmrcdo\Inventory\Models\ProductSku' ,'product_sku_id');
86
+        return $this->belongsTo('Ronmrcdo\Inventory\Models\ProductSku', 'product_sku_id');
87 87
     }
88 88
 
89 89
     /**
Please login to merge, or discard this patch.
src/Models/Attribute.php 2 patches
Indentation   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -8,84 +8,84 @@
 block discarded – undo
8 8
 
9 9
 class Attribute extends Model
10 10
 {
11
-    /**
12
-     * Table name of the model
13
-     * 
14
-     * @var string
15
-     */
16
-    protected $table = 'product_attributes';
11
+	/**
12
+	 * Table name of the model
13
+	 * 
14
+	 * @var string
15
+	 */
16
+	protected $table = 'product_attributes';
17 17
 
18
-    /**
19
-     * Disable the timestamp on model creation
20
-     * 
21
-     * @var bool
22
-     */
23
-    public $timestamps = false;
18
+	/**
19
+	 * Disable the timestamp on model creation
20
+	 * 
21
+	 * @var bool
22
+	 */
23
+	public $timestamps = false;
24 24
 
25
-    /**
26
-     * Fields that are mass assignable
27
-     * 
28
-     * @var array
29
-     */
30
-    protected $fillable = [
31
-        'product_id', 'name'
32
-    ];
25
+	/**
26
+	 * Fields that are mass assignable
27
+	 * 
28
+	 * @var array
29
+	 */
30
+	protected $fillable = [
31
+		'product_id', 'name'
32
+	];
33 33
 
34
-    /**
35
-     * Fields that can't be assign
36
-     * 
37
-     * @var array
38
-     */
39
-    protected $guarded = [
40
-        'id'
41
-    ];
34
+	/**
35
+	 * Fields that can't be assign
36
+	 * 
37
+	 * @var array
38
+	 */
39
+	protected $guarded = [
40
+		'id'
41
+	];
42 42
 
43
-    /**
44
-     * Add Value on the attribute
45
-     * 
46
-     * @param string|array $value
47
-     */
48
-    public function addValue($value)
49
-    {
50
-        if (is_array($value)) {
51
-            $terms = collect($value)->map(function ($term) {
52
-                return ['value' => $term];
53
-            })
54
-            ->values()
55
-            ->toArray();
43
+	/**
44
+	 * Add Value on the attribute
45
+	 * 
46
+	 * @param string|array $value
47
+	 */
48
+	public function addValue($value)
49
+	{
50
+		if (is_array($value)) {
51
+			$terms = collect($value)->map(function ($term) {
52
+				return ['value' => $term];
53
+			})
54
+			->values()
55
+			->toArray();
56 56
 
57
-            return $this->values()->createMany($terms);
58
-        }
59
-        return $this->values()->create(['value' => $value]);
60
-    }
57
+			return $this->values()->createMany($terms);
58
+		}
59
+		return $this->values()->create(['value' => $value]);
60
+	}
61 61
 
62
-    /**
63
-     * Remove a term on an attribute
64
-     * 
65
-     * @param string $term
66
-     */
67
-    public function removeValue($term)
68
-    {
69
-        return $this->values()->where('value', $term)->firstOrFail()->delete();
70
-    }
62
+	/**
63
+	 * Remove a term on an attribute
64
+	 * 
65
+	 * @param string $term
66
+	 */
67
+	public function removeValue($term)
68
+	{
69
+		return $this->values()->where('value', $term)->firstOrFail()->delete();
70
+	}
71 71
 
72
-    /**
73
-     * Relation of the attribute to the product
74
-     * 
75
-     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo $this
76
-     */
77
-    public function product(): BelongsTo
78
-    {
79
-        return $this->belongsTo('Ronmrcdo\Inventory\Models\Product');
80
-    }
72
+	/**
73
+	 * Relation of the attribute to the product
74
+	 * 
75
+	 * @return \Illuminate\Database\Eloquent\Relations\BelongsTo $this
76
+	 */
77
+	public function product(): BelongsTo
78
+	{
79
+		return $this->belongsTo('Ronmrcdo\Inventory\Models\Product');
80
+	}
81 81
 
82
-    /**
83
-     * Relation to the values
84
-     * 
85
-     * @return \Illuminate\Database\Eloquent\Relations\HasMany $this
86
-     */
87
-    public function values(): HasMany
88
-    {
89
-        return $this->hasMany('Ronmrcdo\Inventory\Models\AttributeValue', 'product_attribute_id');
90
-    }
82
+	/**
83
+	 * Relation to the values
84
+	 * 
85
+	 * @return \Illuminate\Database\Eloquent\Relations\HasMany $this
86
+	 */
87
+	public function values(): HasMany
88
+	{
89
+		return $this->hasMany('Ronmrcdo\Inventory\Models\AttributeValue', 'product_attribute_id');
90
+	}
91 91
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@
 block discarded – undo
48 48
     public function addValue($value)
49 49
     {
50 50
         if (is_array($value)) {
51
-            $terms = collect($value)->map(function ($term) {
51
+            $terms = collect($value)->map(function($term) {
52 52
                 return ['value' => $term];
53 53
             })
54 54
             ->values()
Please login to merge, or discard this patch.
src/Models/AttributeValue.php 1 patch
Indentation   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -8,55 +8,55 @@
 block discarded – undo
8 8
 
9 9
 class AttributeValue extends Model
10 10
 {
11
-    /**
12
-     * Table name of the attribute values
13
-     * 
14
-     * @var string
15
-     */
16
-    protected $table = 'product_attribute_values';
17
-
18
-    /**
19
-     * Disable the timestamp on model creation
20
-     * 
21
-     * @var bool
22
-     */
23
-    public $timestamps = false;
24
-
25
-    /**
26
-     * Fields that are mass assignable 
27
-     * 
28
-     * @var array
29
-     */
30
-    protected $fillable = [
31
-        'product_attribute_id', 'value'
32
-    ];
33
-
34
-    /**
35
-     * Fields that can't be assigned
36
-     * 
37
-     * @var array
38
-     */
39
-    protected $guarded = [
40
-        'id'
41
-    ];
42
-
43
-    /**
44
-     * Product Relationship
45
-     * 
46
-     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo $this
47
-     */
48
-    public function attribute(): BelongsTo
49
-    {
50
-        return $this->belongsTo('Ronmrcdo\Inventory\Models\Attribute', 'product_attribute_id');
51
-    }
52
-
53
-    /**
54
-     * Relation of the attribute option to the variant
55
-     * 
56
-     * @return \Illuminate\Database\Eloquent\Relations\HasMany $this
57
-     */
58
-    public function variations(): HasMany
59
-    {
60
-        return $this->hasMany('Ronmrcdo\Inventory\Models\ProductVariant');
61
-    }
11
+	/**
12
+	 * Table name of the attribute values
13
+	 * 
14
+	 * @var string
15
+	 */
16
+	protected $table = 'product_attribute_values';
17
+
18
+	/**
19
+	 * Disable the timestamp on model creation
20
+	 * 
21
+	 * @var bool
22
+	 */
23
+	public $timestamps = false;
24
+
25
+	/**
26
+	 * Fields that are mass assignable 
27
+	 * 
28
+	 * @var array
29
+	 */
30
+	protected $fillable = [
31
+		'product_attribute_id', 'value'
32
+	];
33
+
34
+	/**
35
+	 * Fields that can't be assigned
36
+	 * 
37
+	 * @var array
38
+	 */
39
+	protected $guarded = [
40
+		'id'
41
+	];
42
+
43
+	/**
44
+	 * Product Relationship
45
+	 * 
46
+	 * @return \Illuminate\Database\Eloquent\Relations\BelongsTo $this
47
+	 */
48
+	public function attribute(): BelongsTo
49
+	{
50
+		return $this->belongsTo('Ronmrcdo\Inventory\Models\Attribute', 'product_attribute_id');
51
+	}
52
+
53
+	/**
54
+	 * Relation of the attribute option to the variant
55
+	 * 
56
+	 * @return \Illuminate\Database\Eloquent\Relations\HasMany $this
57
+	 */
58
+	public function variations(): HasMany
59
+	{
60
+		return $this->hasMany('Ronmrcdo\Inventory\Models\ProductVariant');
61
+	}
62 62
 }
Please login to merge, or discard this patch.