Product::summary()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
1
<?php
2
3
namespace FLAIRUK\GoodTillSystem\Models;
4
5
use FLAIRUK\GoodTillSystem\API;
6
use Illuminate\Support\Facades\Config;
7
8
class Product extends API {
9
10
    /**
11
     * The url attribute.
12
     *
13
     * @var string
14
     */
15
    // protected $url = 'https://api.thegoodtill.com/api/products/';
16
17
    /**
18
     * The url attribute.
19
     *
20
     * @var array
21
     */
22
    protected $payload = [];
23
24
    /**
25
     * The url attribute.
26
     *
27
     * @var
28
     */
29
    protected $url;
30
31
    /**
32
     * The url attribute.
33
     *
34
     * @var
35
     */
36
    protected $id;
37
38
    /**
39
     * The url attribute.
40
     *
41
     * @var
42
     */
43
    protected $outlet_id;
44
45
    /**
46
     * The url attribute.
47
     *
48
     * @var 
49
     */
50
    protected $product_name;
51
52
53
    const PRODUCTS = 'products';
54
55
    /**
56
     * Create a new Good Till Product instance.
57
     *
58
     * @param array $user
59
     * @return void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
60
     */
61
    public function __construct(array $user) {
62
        parent::__construct($user, $this->url);
63
    }
64
65
    public function setURL($url = null): void {
66
        $this->url = $url ? $url : Config::get('goodtill.routes.api') . self::PRODUCTS;
67
    }
68
69
    
70
    /**
71
     * Product Set Outlet ID
72
     * 
73
     * @param $id
74
     * @return object
75
     */
76
    public function setID($id): object {
77
        $this->id = $id;
78
        return $this;
79
    }
80
81
    /**
82
     * Product Set Outlet ID
83
     * 
84
     * @param $id
85
     * @return object
86
     */
87
    public function setOutlet($id): object {
88
        $this->outlet_id = ['outlet_id' => $id];
89
        return $this;
90
    }
91
92
   /**
93
     * Product Set Outlet ID
94
     * 
95
     * @param $id
96
     * @return object
97
     */
98
    public function setName($name): object {
99
        $this->product_name = ['product_name' => $name];
100
        // $this->product_name = array_merge($this->payload, ['product_name' => $name ]);
101
        return $this;
102
    }
103
104
       /**
105
     * Product Set Outlet ID
106
     * 
107
     * @return array
108
     */
109
    public function summary($date_range = null): array {
110
        $this->url = $this->url ? $this->url . 'summary' : Config::get('goodtill.routes.api') . 'products/summary';
111
        return $this->create(['daterange' => $date_range]);
112
    }
113
    
114
    // public function payload() {
115
        
116
    //     dump(get_class_vars (Product::Class)); die;
117
    //     return array_merge();
118
    // }
119
120
}
121
122
123
// {
124
//     "id": "3ab9d0b6-6c00-4653-a1f1-926bbdb33727",
125
//     "outlet_id": "aad28387-468f-426c-b0c9-6491f331f12b",
126
//     "category_id": "906bb40e-c202-41e6-a29d-b1bc6bd4cb2d",
127
//     "brand_id": "7d75e12a-2a1c-41ac-861c-9a7e1fbadeaa",
128
//     "supplier_id": "6cebed0e-a7ac-46b6-8d8d-c53012e128e9",
129
//     "vat_code_id": "5cb3c470-3f61-4e45-bffa-1a13a54e27db",
130
//     "parent_product_id": null,
131
//     "product_name": "BERLINER PILSNER",
132
//     "product_sku": "BS",
133
//     "product_desc": "BERLINER PILSNER Description",
134
//     "display_name": "BERLINER PILSNER",
135
//     "barcode": "123456789",
136
//     "weight": 1300,
137
//     "is_loose": 0,
138
//     "is_open_price_product": 0,
139
//     "label_as_main": 0,
140
//     "purchase_price": "2.500",
141
//     "supplier_purchase_price": "2.500",
142
//     "supplier_unit": null,
143
//     "store_to_supplier_unit_conversion": "1.000",
144
//     "selling_price": "4.750",
145
//     "track_inventory": 1,
146
//     "inventory": "0.000",
147
//     "min_stock": "10.000",
148
//     "has_ingredient_stock": 0,
149
//     "take_stock_from_parent": 0,
150
//     "stock_quantifier": "0.000",
151
//     "current_variants": [
152
//         {
153
//             "id": "1bda37bc-24c0-46d0-bb03-707de6142484",
154
//             "product_name": "BERLINER PILSNER Pint",
155
//             "product_sku": "BSPINT",
156
//             "display_name": "BERLINER PILSNER Pint",
157
//             "selling_price": "2.500",
158
//             "child_attributes": {
159
//                 "Size": "Pint"
160
//             },
161
//             "take_stock_from_parent": 0,
162
//             "stock_quantifier": "1.000",
163
//             "inventory": "0.000"
164
//         },
165
//         {
166
//             "id": "cd1b0151-aaaa-4e84-bb9d-8bc45c2d8f28",
167
//             "product_name": "BERLINER PILSNER Half",
168
//             "product_sku": "BSHALF",
169
//             "display_name": "BERLINER PILSNER Half",
170
//             "selling_price": "1.260",
171
//             "child_attributes": {
172
//                 "Size": "Half"
173
//             },
174
//             "take_stock_from_parent": 0,
175
//             "stock_quantifier": "1.000",
176
//             "inventory": "0.000"
177
//         }
178
//     ],
179
//     "alert_on": 1,
180
//     "alert_below": "20.000",
181
//     "delivery_reorder_on": 1,
182
//     "delivery_reorder_point": "20.000",
183
//     "delivery_code": "BSDEL",
184
//     "has_variant": 1,
185
//     "active": 1,
186
//     "shareable": 1,
187
//     "print_on_receipt": 1,
188
//     "print_on_kitchen": 0,
189
//     "print_on_drink": 1,
190
//     "print_on_other": 0,
191
//     "lock_price": 1,
192
//     "display_colour": "2299ee",
193
//     "account_code": null,
194
//     "display_order": 0,
195
//     "tags": [
196
//         "tag 2",
197
//         "tag 3"
198
//     ],
199
//     "has_modifier": 0,
200
//     "ticket_printer_1": 0,
201
//     "ticket_printer_2": 0,
202
//     "ticket_printer_3": 0,
203
//     "ticket_printer_4": 0,
204
//     "has_attributes": 1,
205
//     "display_attr_pos": 1,
206
//     "attributes": [
207
//         "Size"
208
//     ],
209
//     "variants": [
210
//         {
211
//             "product_name": "BERLINER PILSNER Shot",
212
//             "product_sku": "BSSHOT",
213
//             "display_name": "BERLINER PILSNER",
214
//             "selling_price": "1",
215
//             "child_attributes": {
216
//                 "Size": "Shot"
217
//             },
218
//             "take_stock_from_parent": 0,
219
//             "stock_quantifier": 1,
220
//             "inventory": 0
221
//         }
222
//     ],
223
//     "modifier_sets": [
224
//         {
225
//             "id": "aa7a07fa-db81-4eb3-b450-ea102c799f3f"
226
//         },
227
//         {
228
//             "id": "1fd5e9cb-1fda-4982-bf26-e15163e6e1a2"
229
//         }
230
//     ],
231
//     "child_attributes": {
232
//         "Size": "Half"
233
//     }
234
// }