@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | */ |
30 | 30 | public function index(array $data): void |
31 | 31 | { |
32 | - if (empty($data["restaurant_id"]) || !$restaurant_id = filter_var($data["restaurant_id"], FILTER_VALIDATE_INT) ) { |
|
32 | + if (empty($data["restaurant_id"]) || !$restaurant_id = filter_var($data["restaurant_id"], FILTER_VALIDATE_INT)) { |
|
33 | 33 | $this->call( |
34 | 34 | 400, |
35 | 35 | "invalid_data", |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | } |
40 | 40 | |
41 | 41 | //get products |
42 | - $products = (new Product())->find("restaurant_id=:restaurant_id","restaurant_id={$restaurant_id}"); |
|
42 | + $products = (new Product())->find("restaurant_id=:restaurant_id", "restaurant_id={$restaurant_id}"); |
|
43 | 43 | |
44 | 44 | if (!$products->count()) { |
45 | 45 | $this->call( |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | return; |
78 | 78 | } |
79 | 79 | |
80 | - if (empty($data["restaurant_id"]) || !$restaurant_id = filter_var($data["restaurant_id"], FILTER_VALIDATE_INT) ) { |
|
80 | + if (empty($data["restaurant_id"]) || !$restaurant_id = filter_var($data["restaurant_id"], FILTER_VALIDATE_INT)) { |
|
81 | 81 | $this->call( |
82 | 82 | 400, |
83 | 83 | "invalid_data", |
@@ -97,13 +97,13 @@ discard block |
||
97 | 97 | return; |
98 | 98 | } |
99 | 99 | |
100 | - if ( empty($data["category_id"]) || !$category_id = filter_var($data["category_id"], FILTER_VALIDATE_INT) || empty($data["name"]) || empty($data["price"]) ) { |
|
100 | + if (empty($data["category_id"]) || !$category_id = filter_var($data["category_id"], FILTER_VALIDATE_INT) || empty($data["name"]) || empty($data["price"])) { |
|
101 | 101 | $this->call( |
102 | 102 | 400, |
103 | 103 | "empty_data", |
104 | 104 | "Para criar informe o ID da categoria do produto, o nome do produto e o preço do produto" |
105 | 105 | )->back(); |
106 | - return ; |
|
106 | + return; |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | $category = (new ProductCategory())->findById($category_id); |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | $product->old_price = (!empty($data["old_price"])) ? filter_var($data["old_price"], FILTER_SANITIZE_STRIPPED) : 0.00; |
128 | 128 | $product->save(); |
129 | 129 | |
130 | - if($product->fail()){ |
|
130 | + if ($product->fail()) { |
|
131 | 131 | $this->call( |
132 | 132 | 400, |
133 | 133 | "empty_data", |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | */ |
146 | 146 | public function read(array $data): void |
147 | 147 | { |
148 | - if (empty($data["restaurant_id"]) || !$restaurant_id = filter_var($data["restaurant_id"], FILTER_VALIDATE_INT) ) { |
|
148 | + if (empty($data["restaurant_id"]) || !$restaurant_id = filter_var($data["restaurant_id"], FILTER_VALIDATE_INT)) { |
|
149 | 149 | $this->call( |
150 | 150 | 400, |
151 | 151 | "invalid_data", |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | } |
156 | 156 | |
157 | 157 | |
158 | - if (empty($data["product_id"]) || !$product_id = filter_var($data["product_id"], FILTER_VALIDATE_INT) ) { |
|
158 | + if (empty($data["product_id"]) || !$product_id = filter_var($data["product_id"], FILTER_VALIDATE_INT)) { |
|
159 | 159 | $this->call( |
160 | 160 | 400, |
161 | 161 | "invalid_data", |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | */ |
187 | 187 | public function update(array $data): void |
188 | 188 | { |
189 | - if ( empty($data["restaurant_id"]) || !$restaurant_id = filter_var($data["restaurant_id"], FILTER_VALIDATE_INT)) { |
|
189 | + if (empty($data["restaurant_id"]) || !$restaurant_id = filter_var($data["restaurant_id"], FILTER_VALIDATE_INT)) { |
|
190 | 190 | $this->call( |
191 | 191 | 400, |
192 | 192 | "invalid_data", |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | return; |
196 | 196 | } |
197 | 197 | |
198 | - if (empty($data["product_id"]) || !$product_id = filter_var($data["product_id"], FILTER_VALIDATE_INT) ) { |
|
198 | + if (empty($data["product_id"]) || !$product_id = filter_var($data["product_id"], FILTER_VALIDATE_INT)) { |
|
199 | 199 | $this->call( |
200 | 200 | 400, |
201 | 201 | "invalid_data", |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | $product->old_price = (!empty($data["old_price"])) ? filter_var($data["old_price"], FILTER_SANITIZE_STRIPPED) : $product->old_price; |
224 | 224 | $product->save(); |
225 | 225 | |
226 | - if($product->fail()){ |
|
226 | + if ($product->fail()) { |
|
227 | 227 | $this->call( |
228 | 228 | 400, |
229 | 229 | "empty_data", |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | return; |
251 | 251 | } |
252 | 252 | |
253 | - if (empty($data["product_id"]) || !$product_id = filter_var($data["product_id"], FILTER_VALIDATE_INT) ) { |
|
253 | + if (empty($data["product_id"]) || !$product_id = filter_var($data["product_id"], FILTER_VALIDATE_INT)) { |
|
254 | 254 | $this->call( |
255 | 255 | 400, |
256 | 256 | "invalid_data", |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | */ |
29 | 29 | public function index(array $data): void |
30 | 30 | { |
31 | - if (empty($data["restaurant_id"]) || !$restaurant_id = filter_var($data["restaurant_id"], FILTER_VALIDATE_INT) ) { |
|
31 | + if (empty($data["restaurant_id"]) || !$restaurant_id = filter_var($data["restaurant_id"], FILTER_VALIDATE_INT)) { |
|
32 | 32 | $this->call( |
33 | 33 | 400, |
34 | 34 | "invalid_data", |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | } |
39 | 39 | |
40 | 40 | //get products_categories |
41 | - $products_categories = (new ProductCategory())->find("restaurant_id=:restaurant_id","restaurant_id={$restaurant_id}"); |
|
41 | + $products_categories = (new ProductCategory())->find("restaurant_id=:restaurant_id", "restaurant_id={$restaurant_id}"); |
|
42 | 42 | |
43 | 43 | if (!$products_categories->count()) { |
44 | 44 | $this->call( |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | return; |
77 | 77 | } |
78 | 78 | |
79 | - if (empty($data["restaurant_id"]) || !$restaurant_id = filter_var($data["restaurant_id"], FILTER_VALIDATE_INT) ) { |
|
79 | + if (empty($data["restaurant_id"]) || !$restaurant_id = filter_var($data["restaurant_id"], FILTER_VALIDATE_INT)) { |
|
80 | 80 | $this->call( |
81 | 81 | 400, |
82 | 82 | "invalid_data", |
@@ -96,13 +96,13 @@ discard block |
||
96 | 96 | return; |
97 | 97 | } |
98 | 98 | |
99 | - if ( empty($data["name"]) ) { |
|
99 | + if (empty($data["name"])) { |
|
100 | 100 | $this->call( |
101 | 101 | 400, |
102 | 102 | "empty_data", |
103 | 103 | "Para criar informe o nome da categoria" |
104 | 104 | )->back(); |
105 | - return ; |
|
105 | + return; |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | $product_category = new ProductCategory(); |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | $product_category->name = filter_var($data["name"], FILTER_SANITIZE_STRIPPED); |
111 | 111 | $product_category->save(); |
112 | 112 | |
113 | - if($product_category->fail()){ |
|
113 | + if ($product_category->fail()) { |
|
114 | 114 | $this->call( |
115 | 115 | 400, |
116 | 116 | "empty_data", |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | */ |
129 | 129 | public function read(array $data): void |
130 | 130 | { |
131 | - if (empty($data["restaurant_id"]) || !$restaurant_id = filter_var($data["restaurant_id"], FILTER_VALIDATE_INT) ) { |
|
131 | + if (empty($data["restaurant_id"]) || !$restaurant_id = filter_var($data["restaurant_id"], FILTER_VALIDATE_INT)) { |
|
132 | 132 | $this->call( |
133 | 133 | 400, |
134 | 134 | "invalid_data", |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | } |
139 | 139 | |
140 | 140 | |
141 | - if (empty($data["product_category_id"]) || !$product_category_id = filter_var($data["product_category_id"], FILTER_VALIDATE_INT) ) { |
|
141 | + if (empty($data["product_category_id"]) || !$product_category_id = filter_var($data["product_category_id"], FILTER_VALIDATE_INT)) { |
|
142 | 142 | $this->call( |
143 | 143 | 400, |
144 | 144 | "invalid_data", |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | */ |
170 | 170 | public function update(array $data): void |
171 | 171 | { |
172 | - if ( empty($data["restaurant_id"]) || !$restaurant_id = filter_var($data["restaurant_id"], FILTER_VALIDATE_INT)) { |
|
172 | + if (empty($data["restaurant_id"]) || !$restaurant_id = filter_var($data["restaurant_id"], FILTER_VALIDATE_INT)) { |
|
173 | 173 | $this->call( |
174 | 174 | 400, |
175 | 175 | "invalid_data", |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | return; |
179 | 179 | } |
180 | 180 | |
181 | - if (empty($data["product_category_id"]) || !$product_category_id = filter_var($data["product_category_id"], FILTER_VALIDATE_INT) ) { |
|
181 | + if (empty($data["product_category_id"]) || !$product_category_id = filter_var($data["product_category_id"], FILTER_VALIDATE_INT)) { |
|
182 | 182 | $this->call( |
183 | 183 | 400, |
184 | 184 | "invalid_data", |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | $product_category->name = (!empty($data["name"])) ? filter_var($data["name"], FILTER_SANITIZE_STRIPPED) : $product_category->name; |
203 | 203 | $product_category->save(); |
204 | 204 | |
205 | - if($product_category->fail()){ |
|
205 | + if ($product_category->fail()) { |
|
206 | 206 | $this->call( |
207 | 207 | 400, |
208 | 208 | "empty_data", |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | return; |
230 | 230 | } |
231 | 231 | |
232 | - if (empty($data["product_category_id"]) || !$product_category_id = filter_var($data["product_category_id"], FILTER_VALIDATE_INT) ) { |
|
232 | + if (empty($data["product_category_id"]) || !$product_category_id = filter_var($data["product_category_id"], FILTER_VALIDATE_INT)) { |
|
233 | 233 | $this->call( |
234 | 234 | 400, |
235 | 235 | "invalid_data", |