@@ -3,14 +3,14 @@ |
||
| 3 | 3 | $curl = curl_init(); |
| 4 | 4 | |
| 5 | 5 | curl_setopt_array($curl, array( |
| 6 | - CURLOPT_URL => 'https://localhost/v1/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/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); |
@@ -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", |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | { |
| 32 | 32 | $values = $this->headers; |
| 33 | 33 | |
| 34 | - if (empty($data["restaurant_id"]) || !$restaurant_id = filter_var($data["restaurant_id"], FILTER_VALIDATE_INT) ) { |
|
| 34 | + if (empty($data["restaurant_id"]) || !$restaurant_id = filter_var($data["restaurant_id"], FILTER_VALIDATE_INT)) { |
|
| 35 | 35 | $this->call( |
| 36 | 36 | 400, |
| 37 | 37 | "invalid_data", |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | //get products |
| 44 | - $products = (new Product())->find("restaurant_id=:restaurant_id","restaurant_id={$restaurant_id}"); |
|
| 44 | + $products = (new Product())->find("restaurant_id=:restaurant_id", "restaurant_id={$restaurant_id}"); |
|
| 45 | 45 | |
| 46 | 46 | if (!$products->count()) { |
| 47 | 47 | $this->call( |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | return; |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - if (empty($data["restaurant_id"]) || !$restaurant_id = filter_var($data["restaurant_id"], FILTER_VALIDATE_INT) ) { |
|
| 82 | + if (empty($data["restaurant_id"]) || !$restaurant_id = filter_var($data["restaurant_id"], FILTER_VALIDATE_INT)) { |
|
| 83 | 83 | $this->call( |
| 84 | 84 | 400, |
| 85 | 85 | "invalid_data", |
@@ -99,13 +99,13 @@ discard block |
||
| 99 | 99 | return; |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | - if ( empty($data["category_id"]) || !$category_id = filter_var($data["category_id"], FILTER_VALIDATE_INT) || empty($data["name"]) || empty($data["price"]) ) { |
|
| 102 | + if (empty($data["category_id"]) || !$category_id = filter_var($data["category_id"], FILTER_VALIDATE_INT) || empty($data["name"]) || empty($data["price"])) { |
|
| 103 | 103 | $this->call( |
| 104 | 104 | 400, |
| 105 | 105 | "empty_data", |
| 106 | 106 | "Para criar informe o ID da categoria do produto, o nome do produto e o preço do produto" |
| 107 | 107 | )->back(); |
| 108 | - return ; |
|
| 108 | + return; |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | $category = (new ProductCategory())->findById($category_id); |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | $product->old_price = (!empty($data["old_price"])) ? filter_var($data["old_price"], FILTER_SANITIZE_STRIPPED) : 0.00; |
| 130 | 130 | $product->save(); |
| 131 | 131 | |
| 132 | - if($product->fail()){ |
|
| 132 | + if ($product->fail()) { |
|
| 133 | 133 | $this->call( |
| 134 | 134 | 400, |
| 135 | 135 | "empty_data", |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | */ |
| 148 | 148 | public function read(array $data): void |
| 149 | 149 | { |
| 150 | - if (empty($data["restaurant_id"]) || !$restaurant_id = filter_var($data["restaurant_id"], FILTER_VALIDATE_INT) ) { |
|
| 150 | + if (empty($data["restaurant_id"]) || !$restaurant_id = filter_var($data["restaurant_id"], FILTER_VALIDATE_INT)) { |
|
| 151 | 151 | $this->call( |
| 152 | 152 | 400, |
| 153 | 153 | "invalid_data", |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | |
| 160 | - if (empty($data["product_id"]) || !$product_id = filter_var($data["product_id"], FILTER_VALIDATE_INT) ) { |
|
| 160 | + if (empty($data["product_id"]) || !$product_id = filter_var($data["product_id"], FILTER_VALIDATE_INT)) { |
|
| 161 | 161 | $this->call( |
| 162 | 162 | 400, |
| 163 | 163 | "invalid_data", |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | */ |
| 189 | 189 | public function update(array $data): void |
| 190 | 190 | { |
| 191 | - if ( empty($data["restaurant_id"]) || !$restaurant_id = filter_var($data["restaurant_id"], FILTER_VALIDATE_INT)) { |
|
| 191 | + if (empty($data["restaurant_id"]) || !$restaurant_id = filter_var($data["restaurant_id"], FILTER_VALIDATE_INT)) { |
|
| 192 | 192 | $this->call( |
| 193 | 193 | 400, |
| 194 | 194 | "invalid_data", |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | return; |
| 198 | 198 | } |
| 199 | 199 | |
| 200 | - if (empty($data["product_id"]) || !$product_id = filter_var($data["product_id"], FILTER_VALIDATE_INT) ) { |
|
| 200 | + if (empty($data["product_id"]) || !$product_id = filter_var($data["product_id"], FILTER_VALIDATE_INT)) { |
|
| 201 | 201 | $this->call( |
| 202 | 202 | 400, |
| 203 | 203 | "invalid_data", |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | $product->old_price = (!empty($data["old_price"])) ? filter_var($data["old_price"], FILTER_SANITIZE_STRIPPED) : $product->old_price; |
| 226 | 226 | $product->save(); |
| 227 | 227 | |
| 228 | - if($product->fail()){ |
|
| 228 | + if ($product->fail()) { |
|
| 229 | 229 | $this->call( |
| 230 | 230 | 400, |
| 231 | 231 | "empty_data", |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | return; |
| 253 | 253 | } |
| 254 | 254 | |
| 255 | - if (empty($data["product_id"]) || !$product_id = filter_var($data["product_id"], FILTER_VALIDATE_INT) ) { |
|
| 255 | + if (empty($data["product_id"]) || !$product_id = filter_var($data["product_id"], FILTER_VALIDATE_INT)) { |
|
| 256 | 256 | $this->call( |
| 257 | 257 | 400, |
| 258 | 258 | "invalid_data", |