Skip to content
This repository has been archived by the owner on Jul 7, 2021. It is now read-only.

Commit

Permalink
Merge pull request #2 from laravel-enso/update/measurementUnit
Browse files Browse the repository at this point in the history
updates measurement unit & adds default supplier logic
  • Loading branch information
aocneanu authored Sep 2, 2019
2 parents a66dcaa + c28030f commit 3613379
Show file tree
Hide file tree
Showing 48 changed files with 231 additions and 685 deletions.
7 changes: 5 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@
"laravel-enso",
"vue-bulma",
"products",
"products-management"
"product-management"
],
"homepage": "https://github.com/laravel-enso/products",
"require": {
"php": ">=7.1.2",
"laravel-enso/core": "4.3.*",
"laravel-enso/dynamic-methods": "1.0.*",
"laravel-enso/enums": "1.0.*",
"laravel-enso/helpers": "1.11.*"
},
"autoload": {
Expand All @@ -30,7 +32,8 @@
"extra": {
"laravel": {
"providers": [
"LaravelEnso\\Products\\AppServiceProvider"
"LaravelEnso\\Products\\AppServiceProvider",
"LaravelEnso\\Products\\EnumServiceProvider"
]
}
}
Expand Down
11 changes: 11 additions & 0 deletions src/EnumServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

use LaravelEnso\Products\app\Enums\MeasurementUnits;
use LaravelEnso\Enums\EnumServiceProvider as ServiceProvider;

class EnumServiceProvider extends ServiceProvider
{
protected $register = [
'measurementUnits' => MeasurementUnits::class,
];
}
10 changes: 10 additions & 0 deletions src/app/Enums/MeasurementUnits.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace LaravelEnso\Products\app\Enums;

use LaravelEnso\Helpers\app\Classes\Enum;

class MeasurementUnits extends Enum
{
const Piece = 1;
}
28 changes: 0 additions & 28 deletions src/app/Forms/Builders/MeasurementUnitForm.php

This file was deleted.

10 changes: 6 additions & 4 deletions src/app/Forms/Builders/ProductForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@

class ProductForm
{
private const TemplatePath = __DIR__.'/../Templates/product.json';
protected const TemplatePath = __DIR__.'/../Templates/product.json';

private $form;
protected $form;

public function __construct()
{
$this->form = new Form(self::TemplatePath);
$this->form = new Form(static::TemplatePath);
}

public function create()
Expand All @@ -23,6 +23,8 @@ public function create()

public function edit(Product $product)
{
return $this->form->edit($product);
return $this->form
->value('defaultSupplierId', optional($product->defaultSupplier())->id)
->edit($product->inCents(false));
}
}
37 changes: 0 additions & 37 deletions src/app/Forms/Templates/measurementUnit.json

This file was deleted.

38 changes: 34 additions & 4 deletions src/app/Forms/Templates/product.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,32 @@
}
]
},
{
"columns": 2,
"fields": [
{
"label": "Suppliers",
"name": "suppliers",
"value": [],
"meta": {
"custom": true,
"type": "select",
"multiple": true,
"source": "administration.companies.options"
}
},
{
"label": "Default supplier",
"name": "defaultSupplierId",
"value": [],
"meta": {
"custom": true,
"type": "select",
"source": "administration.companies.options"
}
}
]
},
{
"columns": 2,
"fields": [
Expand Down Expand Up @@ -52,11 +78,11 @@
"fields": [
{
"label": "Measurement",
"name": "measurement_unit_id",
"name": "measurement_unit",
"value": null,
"meta": {
"type": "select",
"source": "administration.measurementUnits.options"
"options": "LaravelEnso\\Products\\app\\Enums\\MeasurementUnits"
}
},
{
Expand All @@ -79,7 +105,9 @@
"value": null,
"meta": {
"type": "input",
"content": "number"
"content": "number",
"min": 0,
"step": 0.01
}
},
{
Expand All @@ -88,7 +116,9 @@
"value": null,
"meta": {
"type": "input",
"content": "number"
"content": "number",
"min": 0,
"step": 1
}
}
]
Expand Down
14 changes: 0 additions & 14 deletions src/app/Http/Controllers/MeasurementUnits/Create.php

This file was deleted.

19 changes: 0 additions & 19 deletions src/app/Http/Controllers/MeasurementUnits/Destroy.php

This file was deleted.

15 changes: 0 additions & 15 deletions src/app/Http/Controllers/MeasurementUnits/Edit.php

This file was deleted.

14 changes: 0 additions & 14 deletions src/app/Http/Controllers/MeasurementUnits/ExportExcel.php

This file was deleted.

14 changes: 0 additions & 14 deletions src/app/Http/Controllers/MeasurementUnits/InitTable.php

This file was deleted.

19 changes: 0 additions & 19 deletions src/app/Http/Controllers/MeasurementUnits/Options.php

This file was deleted.

21 changes: 0 additions & 21 deletions src/app/Http/Controllers/MeasurementUnits/Store.php

This file was deleted.

14 changes: 0 additions & 14 deletions src/app/Http/Controllers/MeasurementUnits/TableData.php

This file was deleted.

17 changes: 0 additions & 17 deletions src/app/Http/Controllers/MeasurementUnits/Update.php

This file was deleted.

11 changes: 8 additions & 3 deletions src/app/Http/Controllers/Products/Store.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,18 @@

use Illuminate\Routing\Controller;
use LaravelEnso\Products\app\Models\Product;
use LaravelEnso\Products\app\Http\Requests\ValidateProductRequest;
use LaravelEnso\Products\app\Http\Requests\ValidateProductStore;

class Store extends Controller
{
public function __invoke(ValidateProductRequest $request, Product $product)
public function __invoke(ValidateProductStore $request, Product $product)
{
$product->fill($request->validated())->save();
$product->inCents(false)
->fill($request->validated())->save();

$product->syncSuppliers(
$request->get('suppliers'), $request->get('defaultSupplierId')
);

return [
'message' => __('The product was successfully created'),
Expand Down
Loading

0 comments on commit 3613379

Please sign in to comment.