@@ -1,15 +1,15 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | return [ |
4 | - /** |
|
5 | - * Base Product class |
|
6 | - * |
|
7 | - */ |
|
8 | - 'product' => \Ronmrcdo\Inventory\Models\Product::class, |
|
4 | + /** |
|
5 | + * Base Product class |
|
6 | + * |
|
7 | + */ |
|
8 | + 'product' => \Ronmrcdo\Inventory\Models\Product::class, |
|
9 | 9 | |
10 | - /** |
|
11 | - * Base Category Class |
|
12 | - * |
|
13 | - */ |
|
14 | - 'category' => \Ronmrcdo\Inventory\Models\Category::class |
|
10 | + /** |
|
11 | + * Base Category Class |
|
12 | + * |
|
13 | + */ |
|
14 | + 'category' => \Ronmrcdo\Inventory\Models\Category::class |
|
15 | 15 | ]; |
16 | 16 | \ No newline at end of file |
@@ -7,76 +7,76 @@ |
||
7 | 7 | |
8 | 8 | class ProductVariant extends Model |
9 | 9 | { |
10 | - /** |
|
11 | - * Table name of the model |
|
12 | - * |
|
13 | - * @var string |
|
14 | - */ |
|
15 | - protected $table = 'product_variations'; |
|
10 | + /** |
|
11 | + * Table name of the model |
|
12 | + * |
|
13 | + * @var string |
|
14 | + */ |
|
15 | + protected $table = 'product_variations'; |
|
16 | 16 | |
17 | - /** |
|
18 | - * Disable timestamp |
|
19 | - * |
|
20 | - * @var bool |
|
21 | - */ |
|
22 | - public $timestamps = false; |
|
17 | + /** |
|
18 | + * Disable timestamp |
|
19 | + * |
|
20 | + * @var bool |
|
21 | + */ |
|
22 | + public $timestamps = false; |
|
23 | 23 | |
24 | - /** |
|
25 | - * Fields that can be mass assigned |
|
26 | - * |
|
27 | - * @var array |
|
28 | - */ |
|
29 | - protected $fillable = [ |
|
30 | - 'product_id', 'product_sku_id', 'product_attribute_id', |
|
31 | - 'product_attribute_value_id' |
|
32 | - ]; |
|
24 | + /** |
|
25 | + * Fields that can be mass assigned |
|
26 | + * |
|
27 | + * @var array |
|
28 | + */ |
|
29 | + protected $fillable = [ |
|
30 | + 'product_id', 'product_sku_id', 'product_attribute_id', |
|
31 | + 'product_attribute_value_id' |
|
32 | + ]; |
|
33 | 33 | |
34 | - /** |
|
35 | - * Protected fields during mass assigned |
|
36 | - * |
|
37 | - * @var array |
|
38 | - */ |
|
39 | - protected $guarded = [ |
|
40 | - 'id' |
|
41 | - ]; |
|
34 | + /** |
|
35 | + * Protected fields during mass assigned |
|
36 | + * |
|
37 | + * @var array |
|
38 | + */ |
|
39 | + protected $guarded = [ |
|
40 | + 'id' |
|
41 | + ]; |
|
42 | 42 | |
43 | - /** |
|
44 | - * Relation of the variation to the product sku |
|
45 | - * |
|
46 | - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
|
47 | - */ |
|
48 | - public function productSku(): BelongsTo |
|
43 | + /** |
|
44 | + * Relation of the variation to the product sku |
|
45 | + * |
|
46 | + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
|
47 | + */ |
|
48 | + public function productSku(): BelongsTo |
|
49 | 49 | { |
50 | 50 | return $this->belongsTo('Ronmrcdo\Inventory\Models\ProductSku', 'product_sku_id'); |
51 | 51 | } |
52 | 52 | |
53 | - /** |
|
54 | - * Relation of the variation to the product |
|
55 | - * |
|
56 | - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
|
57 | - */ |
|
58 | - public function product(): BelongsTo |
|
59 | - { |
|
60 | - return $this->belongsTo(config('laravel-inventory.product')); |
|
61 | - } |
|
53 | + /** |
|
54 | + * Relation of the variation to the product |
|
55 | + * |
|
56 | + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
|
57 | + */ |
|
58 | + public function product(): BelongsTo |
|
59 | + { |
|
60 | + return $this->belongsTo(config('laravel-inventory.product')); |
|
61 | + } |
|
62 | 62 | |
63 | - /** |
|
64 | - * Relation of the variation product to the attribute |
|
65 | - * |
|
66 | - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
|
67 | - */ |
|
68 | - public function attribute(): BelongsTo |
|
69 | - { |
|
70 | - return $this->belongsTo('Ronmrcdo\Inventory\Models\Attribute', 'product_attribute_id'); |
|
71 | - } |
|
63 | + /** |
|
64 | + * Relation of the variation product to the attribute |
|
65 | + * |
|
66 | + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
|
67 | + */ |
|
68 | + public function attribute(): BelongsTo |
|
69 | + { |
|
70 | + return $this->belongsTo('Ronmrcdo\Inventory\Models\Attribute', 'product_attribute_id'); |
|
71 | + } |
|
72 | 72 | |
73 | - /** |
|
74 | - * Relation of the variation product to the attribute option |
|
75 | - * |
|
76 | - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
|
77 | - */ |
|
78 | - public function option(): BelongsTo |
|
79 | - { |
|
80 | - return $this->belongsTo('Ronmrcdo\Inventory\Models\AttributeValue', 'product_attribute_value_id'); |
|
81 | - } |
|
73 | + /** |
|
74 | + * Relation of the variation product to the attribute option |
|
75 | + * |
|
76 | + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
|
77 | + */ |
|
78 | + public function option(): BelongsTo |
|
79 | + { |
|
80 | + return $this->belongsTo('Ronmrcdo\Inventory\Models\AttributeValue', 'product_attribute_value_id'); |
|
81 | + } |
|
82 | 82 | } |
@@ -8,84 +8,84 @@ |
||
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(config('laravel-inventory.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(config('laravel-inventory.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 | } |
@@ -8,65 +8,65 @@ |
||
8 | 8 | |
9 | 9 | class ProductSku extends Model |
10 | 10 | { |
11 | - /** |
|
12 | - * Table name of the model |
|
13 | - * |
|
14 | - * @var string |
|
15 | - */ |
|
16 | - protected $table = 'product_skus'; |
|
11 | + /** |
|
12 | + * Table name of the model |
|
13 | + * |
|
14 | + * @var string |
|
15 | + */ |
|
16 | + protected $table = 'product_skus'; |
|
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 can be mass assigned |
|
27 | - * |
|
28 | - * @var array |
|
29 | - */ |
|
30 | - protected $fillable = [ |
|
31 | - 'product_id', 'code', 'price', 'cost' |
|
32 | - ]; |
|
25 | + /** |
|
26 | + * Fields that can be mass assigned |
|
27 | + * |
|
28 | + * @var array |
|
29 | + */ |
|
30 | + protected $fillable = [ |
|
31 | + 'product_id', 'code', 'price', 'cost' |
|
32 | + ]; |
|
33 | 33 | |
34 | - /** |
|
35 | - * Fields that are guarded during mass assign |
|
36 | - * |
|
37 | - * @var array |
|
38 | - */ |
|
39 | - protected $guarded = [ |
|
40 | - 'id' |
|
41 | - ]; |
|
34 | + /** |
|
35 | + * Fields that are guarded during mass assign |
|
36 | + * |
|
37 | + * @var array |
|
38 | + */ |
|
39 | + protected $guarded = [ |
|
40 | + 'id' |
|
41 | + ]; |
|
42 | 42 | |
43 | - /** |
|
44 | - * Relation to the product |
|
45 | - * |
|
46 | - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
|
47 | - */ |
|
48 | - public function product(): BelongsTo |
|
49 | - { |
|
50 | - return $this->belongsTo(config('laravel-inventory.product')); |
|
51 | - } |
|
43 | + /** |
|
44 | + * Relation to the product |
|
45 | + * |
|
46 | + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
|
47 | + */ |
|
48 | + public function product(): BelongsTo |
|
49 | + { |
|
50 | + return $this->belongsTo(config('laravel-inventory.product')); |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * Product Variant |
|
55 | - * |
|
56 | - * @return \Illuminate\Database\Eloquent\Relations\HasMany |
|
57 | - */ |
|
58 | - public function variant(): HasMany |
|
59 | - { |
|
60 | - return $this->hasMany('Ronmrcdo\Inventory\Models\ProductVariant', 'product_sku_id'); |
|
61 | - } |
|
53 | + /** |
|
54 | + * Product Variant |
|
55 | + * |
|
56 | + * @return \Illuminate\Database\Eloquent\Relations\HasMany |
|
57 | + */ |
|
58 | + public function variant(): HasMany |
|
59 | + { |
|
60 | + return $this->hasMany('Ronmrcdo\Inventory\Models\ProductVariant', 'product_sku_id'); |
|
61 | + } |
|
62 | 62 | |
63 | - /** |
|
64 | - * Product sku has many stocks |
|
65 | - * |
|
66 | - * @return \Illuminate\Database\Eloquent\Relations\HasMany |
|
67 | - */ |
|
68 | - public function stocks(): HasMany |
|
69 | - { |
|
70 | - return $this->hasMany('Ronmrcdo\Inventory\Models\InventoryStock'); |
|
71 | - } |
|
63 | + /** |
|
64 | + * Product sku has many stocks |
|
65 | + * |
|
66 | + * @return \Illuminate\Database\Eloquent\Relations\HasMany |
|
67 | + */ |
|
68 | + public function stocks(): HasMany |
|
69 | + { |
|
70 | + return $this->hasMany('Ronmrcdo\Inventory\Models\InventoryStock'); |
|
71 | + } |
|
72 | 72 | } |
@@ -14,9 +14,9 @@ discard block |
||
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 | /** |
@@ -30,14 +30,14 @@ discard block |
||
30 | 30 | } |
31 | 31 | |
32 | 32 | /** |
33 | - * Get the services provided by the provider. |
|
34 | - * |
|
35 | - * @return array |
|
36 | - */ |
|
37 | - public function provides() |
|
38 | - { |
|
39 | - return ['inventory']; |
|
40 | - } |
|
33 | + * Get the services provided by the provider. |
|
34 | + * |
|
35 | + * @return array |
|
36 | + */ |
|
37 | + public function provides() |
|
38 | + { |
|
39 | + return ['inventory']; |
|
40 | + } |
|
41 | 41 | |
42 | 42 | /** |
43 | 43 | * Register the bootable configurations |
@@ -47,13 +47,13 @@ discard block |
||
47 | 47 | protected function bootForConsole(): void |
48 | 48 | { |
49 | 49 | $this->publishes([ |
50 | - __DIR__.'/../config/laravel-inventory.php' => base_path('config/laravel-inventory.php'), |
|
50 | + __DIR__.'/../config/laravel-inventory.php' => base_path('config/laravel-inventory.php'), |
|
51 | 51 | ], 'config'); |
52 | 52 | |
53 | 53 | $this->loadMigrationsFrom(__DIR__.'/../database/migrations'); |
54 | 54 | |
55 | 55 | $this->publishes([ |
56 | - __DIR__.'/../database/migrations' => database_path('migrations') |
|
57 | - ], 'migrations'); |
|
56 | + __DIR__.'/../database/migrations' => database_path('migrations') |
|
57 | + ], 'migrations'); |
|
58 | 58 | } |
59 | 59 | } |
60 | 60 | \ No newline at end of file |