@@ -15,7 +15,7 @@ |
||
15 | 15 | |
16 | 16 | $response = curl_exec($curl); |
17 | 17 | $err = curl_errno($curl); |
18 | -$errmsg = curl_error($curl) ; |
|
18 | +$errmsg = curl_error($curl); |
|
19 | 19 | |
20 | 20 | curl_close($curl); |
21 | 21 |
@@ -3,14 +3,14 @@ |
||
3 | 3 | $curl = curl_init(); |
4 | 4 | |
5 | 5 | curl_setopt_array($curl, array( |
6 | - CURLOPT_URL => 'https://localhost/v1/restaurants/1/products/1', |
|
7 | - CURLOPT_RETURNTRANSFER => true, |
|
8 | - CURLOPT_ENCODING => '', |
|
9 | - CURLOPT_MAXREDIRS => 10, |
|
10 | - CURLOPT_TIMEOUT => 0, |
|
11 | - CURLOPT_FOLLOWLOCATION => true, |
|
12 | - CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, |
|
13 | - CURLOPT_CUSTOMREQUEST => 'GET', |
|
6 | + CURLOPT_URL => 'https://localhost/v1/restaurants/1/products/1', |
|
7 | + CURLOPT_RETURNTRANSFER => true, |
|
8 | + CURLOPT_ENCODING => '', |
|
9 | + CURLOPT_MAXREDIRS => 10, |
|
10 | + CURLOPT_TIMEOUT => 0, |
|
11 | + CURLOPT_FOLLOWLOCATION => true, |
|
12 | + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, |
|
13 | + CURLOPT_CUSTOMREQUEST => 'GET', |
|
14 | 14 | )); |
15 | 15 | |
16 | 16 | $response = curl_exec($curl); |
@@ -15,7 +15,7 @@ |
||
15 | 15 | |
16 | 16 | $response = curl_exec($curl); |
17 | 17 | $err = curl_errno($curl); |
18 | -$errmsg = curl_error($curl) ; |
|
18 | +$errmsg = curl_error($curl); |
|
19 | 19 | |
20 | 20 | curl_close($curl); |
21 | 21 |
@@ -3,17 +3,17 @@ |
||
3 | 3 | $curl = curl_init(); |
4 | 4 | |
5 | 5 | curl_setopt_array($curl, array( |
6 | - CURLOPT_URL => 'https://goomerapi.test/v1/restaurants/1/categories', |
|
7 | - CURLOPT_RETURNTRANSFER => true, |
|
8 | - CURLOPT_ENCODING => '', |
|
9 | - CURLOPT_MAXREDIRS => 10, |
|
10 | - CURLOPT_TIMEOUT => 0, |
|
11 | - CURLOPT_FOLLOWLOCATION => true, |
|
12 | - CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, |
|
13 | - CURLOPT_CUSTOMREQUEST => 'GET', |
|
14 | - CURLOPT_HTTPHEADER => array( |
|
6 | + CURLOPT_URL => 'https://goomerapi.test/v1/restaurants/1/categories', |
|
7 | + CURLOPT_RETURNTRANSFER => true, |
|
8 | + CURLOPT_ENCODING => '', |
|
9 | + CURLOPT_MAXREDIRS => 10, |
|
10 | + CURLOPT_TIMEOUT => 0, |
|
11 | + CURLOPT_FOLLOWLOCATION => true, |
|
12 | + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, |
|
13 | + CURLOPT_CUSTOMREQUEST => 'GET', |
|
14 | + CURLOPT_HTTPHEADER => array( |
|
15 | 15 | 'page: 1' |
16 | - ), |
|
16 | + ), |
|
17 | 17 | )); |
18 | 18 | |
19 | 19 | $response = curl_exec($curl); |
@@ -15,7 +15,7 @@ |
||
15 | 15 | |
16 | 16 | $response = curl_exec($curl); |
17 | 17 | $err = curl_errno($curl); |
18 | -$errmsg = curl_error($curl) ; |
|
18 | +$errmsg = curl_error($curl); |
|
19 | 19 | |
20 | 20 | curl_close($curl); |
21 | 21 |
@@ -3,15 +3,15 @@ |
||
3 | 3 | $curl = curl_init(); |
4 | 4 | |
5 | 5 | curl_setopt_array($curl, array( |
6 | - CURLOPT_URL => 'https://goomerapi.test/v1/restaurants/1/categories/1', |
|
7 | - CURLOPT_RETURNTRANSFER => true, |
|
8 | - CURLOPT_ENCODING => '', |
|
9 | - CURLOPT_MAXREDIRS => 10, |
|
10 | - CURLOPT_TIMEOUT => 0, |
|
11 | - CURLOPT_FOLLOWLOCATION => true, |
|
12 | - CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, |
|
13 | - CURLOPT_CUSTOMREQUEST => 'PUT', |
|
14 | - CURLOPT_POSTFIELDS => 'name=Categoria%20Goomer%20Api', |
|
6 | + CURLOPT_URL => 'https://goomerapi.test/v1/restaurants/1/categories/1', |
|
7 | + CURLOPT_RETURNTRANSFER => true, |
|
8 | + CURLOPT_ENCODING => '', |
|
9 | + CURLOPT_MAXREDIRS => 10, |
|
10 | + CURLOPT_TIMEOUT => 0, |
|
11 | + CURLOPT_FOLLOWLOCATION => true, |
|
12 | + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, |
|
13 | + CURLOPT_CUSTOMREQUEST => 'PUT', |
|
14 | + CURLOPT_POSTFIELDS => 'name=Categoria%20Goomer%20Api', |
|
15 | 15 | )); |
16 | 16 | |
17 | 17 | $response = curl_exec($curl); |
@@ -15,7 +15,7 @@ |
||
15 | 15 | |
16 | 16 | $response = curl_exec($curl); |
17 | 17 | $err = curl_errno($curl); |
18 | -$errmsg = curl_error($curl) ; |
|
18 | +$errmsg = curl_error($curl); |
|
19 | 19 | |
20 | 20 | curl_close($curl); |
21 | 21 |
@@ -3,15 +3,15 @@ |
||
3 | 3 | $curl = curl_init(); |
4 | 4 | |
5 | 5 | curl_setopt_array($curl, array( |
6 | - CURLOPT_URL => 'https://goomerapi.test/v1/restaurants/1/categories', |
|
7 | - CURLOPT_RETURNTRANSFER => true, |
|
8 | - CURLOPT_ENCODING => '', |
|
9 | - CURLOPT_MAXREDIRS => 10, |
|
10 | - CURLOPT_TIMEOUT => 0, |
|
11 | - CURLOPT_FOLLOWLOCATION => true, |
|
12 | - CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, |
|
13 | - CURLOPT_CUSTOMREQUEST => 'POST', |
|
14 | - CURLOPT_POSTFIELDS => array('name' => 'Categoria Goomer'), |
|
6 | + CURLOPT_URL => 'https://goomerapi.test/v1/restaurants/1/categories', |
|
7 | + CURLOPT_RETURNTRANSFER => true, |
|
8 | + CURLOPT_ENCODING => '', |
|
9 | + CURLOPT_MAXREDIRS => 10, |
|
10 | + CURLOPT_TIMEOUT => 0, |
|
11 | + CURLOPT_FOLLOWLOCATION => true, |
|
12 | + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, |
|
13 | + CURLOPT_CUSTOMREQUEST => 'POST', |
|
14 | + CURLOPT_POSTFIELDS => array('name' => 'Categoria Goomer'), |
|
15 | 15 | )); |
16 | 16 | |
17 | 17 | $response = curl_exec($curl); |
@@ -15,7 +15,7 @@ |
||
15 | 15 | |
16 | 16 | $response = curl_exec($curl); |
17 | 17 | $err = curl_errno($curl); |
18 | -$errmsg = curl_error($curl) ; |
|
18 | +$errmsg = curl_error($curl); |
|
19 | 19 | |
20 | 20 | curl_close($curl); |
21 | 21 |
@@ -3,14 +3,14 @@ |
||
3 | 3 | $curl = curl_init(); |
4 | 4 | |
5 | 5 | curl_setopt_array($curl, array( |
6 | - CURLOPT_URL => 'https://goomerapi.test/v1/restaurants/1/categories/1', |
|
7 | - CURLOPT_RETURNTRANSFER => true, |
|
8 | - CURLOPT_ENCODING => '', |
|
9 | - CURLOPT_MAXREDIRS => 10, |
|
10 | - CURLOPT_TIMEOUT => 0, |
|
11 | - CURLOPT_FOLLOWLOCATION => true, |
|
12 | - CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, |
|
13 | - CURLOPT_CUSTOMREQUEST => 'GET', |
|
6 | + CURLOPT_URL => 'https://goomerapi.test/v1/restaurants/1/categories/1', |
|
7 | + CURLOPT_RETURNTRANSFER => true, |
|
8 | + CURLOPT_ENCODING => '', |
|
9 | + CURLOPT_MAXREDIRS => 10, |
|
10 | + CURLOPT_TIMEOUT => 0, |
|
11 | + CURLOPT_FOLLOWLOCATION => true, |
|
12 | + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, |
|
13 | + CURLOPT_CUSTOMREQUEST => 'GET', |
|
14 | 14 | )); |
15 | 15 | |
16 | 16 | $response = curl_exec($curl); |
@@ -15,7 +15,7 @@ |
||
15 | 15 | |
16 | 16 | $response = curl_exec($curl); |
17 | 17 | $err = curl_errno($curl); |
18 | -$errmsg = curl_error($curl) ; |
|
18 | +$errmsg = curl_error($curl); |
|
19 | 19 | |
20 | 20 | curl_close($curl); |
21 | 21 |
@@ -3,14 +3,14 @@ |
||
3 | 3 | $curl = curl_init(); |
4 | 4 | |
5 | 5 | curl_setopt_array($curl, array( |
6 | - CURLOPT_URL => 'https://goomerapi.test/v1/restaurants/1/categories/1', |
|
7 | - CURLOPT_RETURNTRANSFER => true, |
|
8 | - CURLOPT_ENCODING => '', |
|
9 | - CURLOPT_MAXREDIRS => 10, |
|
10 | - CURLOPT_TIMEOUT => 0, |
|
11 | - CURLOPT_FOLLOWLOCATION => true, |
|
12 | - CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, |
|
13 | - CURLOPT_CUSTOMREQUEST => 'DELETE', |
|
6 | + CURLOPT_URL => 'https://goomerapi.test/v1/restaurants/1/categories/1', |
|
7 | + CURLOPT_RETURNTRANSFER => true, |
|
8 | + CURLOPT_ENCODING => '', |
|
9 | + CURLOPT_MAXREDIRS => 10, |
|
10 | + CURLOPT_TIMEOUT => 0, |
|
11 | + CURLOPT_FOLLOWLOCATION => true, |
|
12 | + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, |
|
13 | + CURLOPT_CUSTOMREQUEST => 'DELETE', |
|
14 | 14 | )); |
15 | 15 | |
16 | 16 | $response = curl_exec($curl); |
@@ -11,12 +11,12 @@ |
||
11 | 11 | CURLOPT_FOLLOWLOCATION => true, |
12 | 12 | CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, |
13 | 13 | CURLOPT_CUSTOMREQUEST => 'POST', |
14 | - CURLOPT_POSTFIELDS => array('category_id' =>1,'name' => 'Produto Goomer','price' => '20.5','image' => 'image/img.jpg','description' => 'Teste de criação de produtos','old_price' => '0.00'), |
|
14 | + CURLOPT_POSTFIELDS => array('category_id' =>1, 'name' => 'Produto Goomer', 'price' => '20.5', 'image' => 'image/img.jpg', 'description' => 'Teste de criação de produtos', 'old_price' => '0.00'), |
|
15 | 15 | )); |
16 | 16 | |
17 | 17 | $response = curl_exec($curl); |
18 | 18 | $err = curl_errno($curl); |
19 | -$errmsg = curl_error($curl) ; |
|
19 | +$errmsg = curl_error($curl); |
|
20 | 20 | |
21 | 21 | curl_close($curl); |
22 | 22 |
@@ -3,15 +3,15 @@ |
||
3 | 3 | $curl = curl_init(); |
4 | 4 | |
5 | 5 | curl_setopt_array($curl, array( |
6 | - CURLOPT_URL => 'https://localhost/v1/restaurants/1/products', |
|
7 | - CURLOPT_RETURNTRANSFER => true, |
|
8 | - CURLOPT_ENCODING => '', |
|
9 | - CURLOPT_MAXREDIRS => 10, |
|
10 | - CURLOPT_TIMEOUT => 0, |
|
11 | - CURLOPT_FOLLOWLOCATION => true, |
|
12 | - CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, |
|
13 | - CURLOPT_CUSTOMREQUEST => 'POST', |
|
14 | - CURLOPT_POSTFIELDS => array('category_id' =>1,'name' => 'Produto Goomer','price' => '20.5','image' => 'image/img.jpg','description' => 'Teste de criação de produtos','old_price' => '0.00'), |
|
6 | + CURLOPT_URL => 'https://localhost/v1/restaurants/1/products', |
|
7 | + CURLOPT_RETURNTRANSFER => true, |
|
8 | + CURLOPT_ENCODING => '', |
|
9 | + CURLOPT_MAXREDIRS => 10, |
|
10 | + CURLOPT_TIMEOUT => 0, |
|
11 | + CURLOPT_FOLLOWLOCATION => true, |
|
12 | + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, |
|
13 | + CURLOPT_CUSTOMREQUEST => 'POST', |
|
14 | + CURLOPT_POSTFIELDS => array('category_id' =>1,'name' => 'Produto Goomer','price' => '20.5','image' => 'image/img.jpg','description' => 'Teste de criação de produtos','old_price' => '0.00'), |
|
15 | 15 | )); |
16 | 16 | |
17 | 17 | $response = curl_exec($curl); |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | { |
31 | 31 | $values = $this->headers; |
32 | 32 | |
33 | - if (empty($data["restaurant_id"]) || !$restaurant_id = filter_var($data["restaurant_id"], FILTER_VALIDATE_INT) ) { |
|
33 | + if (empty($data["restaurant_id"]) || !$restaurant_id = filter_var($data["restaurant_id"], FILTER_VALIDATE_INT)) { |
|
34 | 34 | $this->call( |
35 | 35 | 400, |
36 | 36 | "invalid_data", |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | } |
41 | 41 | |
42 | 42 | //get products_categories |
43 | - $products_categories = (new ProductCategory())->find("restaurant_id=:restaurant_id","restaurant_id={$restaurant_id}"); |
|
43 | + $products_categories = (new ProductCategory())->find("restaurant_id=:restaurant_id", "restaurant_id={$restaurant_id}"); |
|
44 | 44 | |
45 | 45 | if (!$products_categories->count()) { |
46 | 46 | $this->call( |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | return; |
79 | 79 | } |
80 | 80 | |
81 | - if (empty($data["restaurant_id"]) || !$restaurant_id = filter_var($data["restaurant_id"], FILTER_VALIDATE_INT) ) { |
|
81 | + if (empty($data["restaurant_id"]) || !$restaurant_id = filter_var($data["restaurant_id"], FILTER_VALIDATE_INT)) { |
|
82 | 82 | $this->call( |
83 | 83 | 400, |
84 | 84 | "invalid_data", |
@@ -98,13 +98,13 @@ discard block |
||
98 | 98 | return; |
99 | 99 | } |
100 | 100 | |
101 | - if ( empty($data["name"]) ) { |
|
101 | + if (empty($data["name"])) { |
|
102 | 102 | $this->call( |
103 | 103 | 400, |
104 | 104 | "empty_data", |
105 | 105 | "Para criar informe o nome da categoria" |
106 | 106 | )->back(); |
107 | - return ; |
|
107 | + return; |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | $product_category = new ProductCategory(); |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | $product_category->name = filter_var($data["name"], FILTER_SANITIZE_STRIPPED); |
113 | 113 | $product_category->save(); |
114 | 114 | |
115 | - if($product_category->fail()){ |
|
115 | + if ($product_category->fail()) { |
|
116 | 116 | $this->call( |
117 | 117 | 400, |
118 | 118 | "empty_data", |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | */ |
131 | 131 | public function read(array $data): void |
132 | 132 | { |
133 | - if (empty($data["restaurant_id"]) || !$restaurant_id = filter_var($data["restaurant_id"], FILTER_VALIDATE_INT) ) { |
|
133 | + if (empty($data["restaurant_id"]) || !$restaurant_id = filter_var($data["restaurant_id"], FILTER_VALIDATE_INT)) { |
|
134 | 134 | $this->call( |
135 | 135 | 400, |
136 | 136 | "invalid_data", |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | } |
141 | 141 | |
142 | 142 | |
143 | - if (empty($data["product_category_id"]) || !$product_category_id = filter_var($data["product_category_id"], FILTER_VALIDATE_INT) ) { |
|
143 | + if (empty($data["product_category_id"]) || !$product_category_id = filter_var($data["product_category_id"], FILTER_VALIDATE_INT)) { |
|
144 | 144 | $this->call( |
145 | 145 | 400, |
146 | 146 | "invalid_data", |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | */ |
172 | 172 | public function update(array $data): void |
173 | 173 | { |
174 | - if ( empty($data["restaurant_id"]) || !$restaurant_id = filter_var($data["restaurant_id"], FILTER_VALIDATE_INT)) { |
|
174 | + if (empty($data["restaurant_id"]) || !$restaurant_id = filter_var($data["restaurant_id"], FILTER_VALIDATE_INT)) { |
|
175 | 175 | $this->call( |
176 | 176 | 400, |
177 | 177 | "invalid_data", |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | return; |
181 | 181 | } |
182 | 182 | |
183 | - if (empty($data["product_category_id"]) || !$product_category_id = filter_var($data["product_category_id"], FILTER_VALIDATE_INT) ) { |
|
183 | + if (empty($data["product_category_id"]) || !$product_category_id = filter_var($data["product_category_id"], FILTER_VALIDATE_INT)) { |
|
184 | 184 | $this->call( |
185 | 185 | 400, |
186 | 186 | "invalid_data", |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | $product_category->name = (!empty($data["name"])) ? filter_var($data["name"], FILTER_SANITIZE_STRIPPED) : $product_category->name; |
205 | 205 | $product_category->save(); |
206 | 206 | |
207 | - if($product_category->fail()){ |
|
207 | + if ($product_category->fail()) { |
|
208 | 208 | $this->call( |
209 | 209 | 400, |
210 | 210 | "empty_data", |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | return; |
232 | 232 | } |
233 | 233 | |
234 | - if (empty($data["product_category_id"]) || !$product_category_id = filter_var($data["product_category_id"], FILTER_VALIDATE_INT) ) { |
|
234 | + if (empty($data["product_category_id"]) || !$product_category_id = filter_var($data["product_category_id"], FILTER_VALIDATE_INT)) { |
|
235 | 235 | $this->call( |
236 | 236 | 400, |
237 | 237 | "invalid_data", |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | $params = ""; |
34 | 34 | $values = $this->headers; |
35 | 35 | |
36 | - if (empty($data["restaurant_id"]) || !$restaurant_id = filter_var($data["restaurant_id"], FILTER_VALIDATE_INT) ) { |
|
36 | + if (empty($data["restaurant_id"]) || !$restaurant_id = filter_var($data["restaurant_id"], FILTER_VALIDATE_INT)) { |
|
37 | 37 | $this->call( |
38 | 38 | 400, |
39 | 39 | "invalid_data", |
@@ -41,11 +41,11 @@ discard block |
||
41 | 41 | )->back(); |
42 | 42 | return; |
43 | 43 | } |
44 | - $category_id = explode('&',$_SERVER['REQUEST_URI']); |
|
44 | + $category_id = explode('&', $_SERVER['REQUEST_URI']); |
|
45 | 45 | |
46 | 46 | if (!empty($category_id) && count($category_id) == 2) { |
47 | - $category = explode('=',$category_id[1]); |
|
48 | - if($category[0] == 'category_id'){ |
|
47 | + $category = explode('=', $category_id[1]); |
|
48 | + if ($category[0] == 'category_id') { |
|
49 | 49 | $category_id = filter_var($category[1], FILTER_VALIDATE_INT); |
50 | 50 | $where = " AND category_id=:category_id"; |
51 | 51 | $params = "&category_id={$category_id}"; |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | } |
54 | 54 | |
55 | 55 | //get products |
56 | - $products = (new Product())->find("restaurant_id=:restaurant_id{$where}","restaurant_id={$restaurant_id}{$params}"); |
|
56 | + $products = (new Product())->find("restaurant_id=:restaurant_id{$where}", "restaurant_id={$restaurant_id}{$params}"); |
|
57 | 57 | |
58 | 58 | if (!$products->count()) { |
59 | 59 | $this->call( |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | return; |
92 | 92 | } |
93 | 93 | |
94 | - if (empty($data["restaurant_id"]) || !$restaurant_id = filter_var($data["restaurant_id"], FILTER_VALIDATE_INT) ) { |
|
94 | + if (empty($data["restaurant_id"]) || !$restaurant_id = filter_var($data["restaurant_id"], FILTER_VALIDATE_INT)) { |
|
95 | 95 | $this->call( |
96 | 96 | 400, |
97 | 97 | "invalid_data", |
@@ -111,13 +111,13 @@ discard block |
||
111 | 111 | return; |
112 | 112 | } |
113 | 113 | |
114 | - if ( empty($data["category_id"]) || !$category_id = filter_var($data["category_id"], FILTER_VALIDATE_INT) || empty($data["name"]) || empty($data["price"]) ) { |
|
114 | + if (empty($data["category_id"]) || !$category_id = filter_var($data["category_id"], FILTER_VALIDATE_INT) || empty($data["name"]) || empty($data["price"])) { |
|
115 | 115 | $this->call( |
116 | 116 | 400, |
117 | 117 | "empty_data", |
118 | 118 | "Para criar informe o ID da categoria do produto, o nome do produto e o preço do produto" |
119 | 119 | )->back(); |
120 | - return ; |
|
120 | + return; |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | $category = (new ProductCategory())->findById($category_id); |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | $product->old_price = (!empty($data["old_price"])) ? filter_var($data["old_price"], FILTER_SANITIZE_STRIPPED) : 0.00; |
142 | 142 | $product->save(); |
143 | 143 | |
144 | - if($product->fail()){ |
|
144 | + if ($product->fail()) { |
|
145 | 145 | $this->call( |
146 | 146 | 400, |
147 | 147 | "empty_data", |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | */ |
160 | 160 | public function read(array $data): void |
161 | 161 | { |
162 | - if (empty($data["restaurant_id"]) || !$restaurant_id = filter_var($data["restaurant_id"], FILTER_VALIDATE_INT) ) { |
|
162 | + if (empty($data["restaurant_id"]) || !$restaurant_id = filter_var($data["restaurant_id"], FILTER_VALIDATE_INT)) { |
|
163 | 163 | $this->call( |
164 | 164 | 400, |
165 | 165 | "invalid_data", |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | } |
170 | 170 | |
171 | 171 | |
172 | - if (empty($data["product_id"]) || !$product_id = filter_var($data["product_id"], FILTER_VALIDATE_INT) ) { |
|
172 | + if (empty($data["product_id"]) || !$product_id = filter_var($data["product_id"], FILTER_VALIDATE_INT)) { |
|
173 | 173 | $this->call( |
174 | 174 | 400, |
175 | 175 | "invalid_data", |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | */ |
201 | 201 | public function update(array $data): void |
202 | 202 | { |
203 | - if ( empty($data["restaurant_id"]) || !$restaurant_id = filter_var($data["restaurant_id"], FILTER_VALIDATE_INT)) { |
|
203 | + if (empty($data["restaurant_id"]) || !$restaurant_id = filter_var($data["restaurant_id"], FILTER_VALIDATE_INT)) { |
|
204 | 204 | $this->call( |
205 | 205 | 400, |
206 | 206 | "invalid_data", |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | return; |
210 | 210 | } |
211 | 211 | |
212 | - if (empty($data["product_id"]) || !$product_id = filter_var($data["product_id"], FILTER_VALIDATE_INT) ) { |
|
212 | + if (empty($data["product_id"]) || !$product_id = filter_var($data["product_id"], FILTER_VALIDATE_INT)) { |
|
213 | 213 | $this->call( |
214 | 214 | 400, |
215 | 215 | "invalid_data", |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | $product->old_price = (!empty($data["old_price"])) ? filter_var($data["old_price"], FILTER_SANITIZE_STRIPPED) : $product->old_price; |
238 | 238 | $product->save(); |
239 | 239 | |
240 | - if($product->fail()){ |
|
240 | + if ($product->fail()) { |
|
241 | 241 | $this->call( |
242 | 242 | 400, |
243 | 243 | "empty_data", |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | return; |
265 | 265 | } |
266 | 266 | |
267 | - if (empty($data["product_id"]) || !$product_id = filter_var($data["product_id"], FILTER_VALIDATE_INT) ) { |
|
267 | + if (empty($data["product_id"]) || !$product_id = filter_var($data["product_id"], FILTER_VALIDATE_INT)) { |
|
268 | 268 | $this->call( |
269 | 269 | 400, |
270 | 270 | "invalid_data", |