@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | class AdController extends Controller |
13 | 13 | { |
14 | 14 | |
15 | - public function addAnnounce(Request $request){ |
|
15 | + public function addAnnounce(Request $request) { |
|
16 | 16 | |
17 | 17 | $file = null; |
18 | 18 | |
@@ -32,14 +32,14 @@ discard block |
||
32 | 32 | // Check to see if validation fails or passes |
33 | 33 | if ($validator->fails()) |
34 | 34 | { |
35 | - return response()->json(['data' => 'Fichier invalid', 'state' => false]); |
|
35 | + return response()->json([ 'data' => 'Fichier invalid', 'state' => false ]); |
|
36 | 36 | } else { |
37 | 37 | if ($request->hasFile('image')) { |
38 | 38 | $file = $request->file('image'); |
39 | 39 | $filename = $file->getClientOriginalName(); // Récupère le nom original du fichier |
40 | 40 | $destinationPath = public_path().'/uploads/ad'; // Indique où stocker le fichier |
41 | 41 | $file->move($destinationPath, $filename); // Déplace le fichier |
42 | - return response()->json(['data' => asset($filename), 'state' => true]); |
|
42 | + return response()->json([ 'data' => asset($filename), 'state' => true ]); |
|
43 | 43 | } |
44 | 44 | } |
45 | 45 |
@@ -35,14 +35,14 @@ discard block |
||
35 | 35 | 'created' => new \DateTime("now"), |
36 | 36 | ]; |
37 | 37 | |
38 | - try{ |
|
38 | + try { |
|
39 | 39 | $collection->insertOne($stat); |
40 | - }catch (\Exception $e){ |
|
41 | - return response()->json(['state' => false]); |
|
40 | + } catch (\Exception $e) { |
|
41 | + return response()->json([ 'state' => false ]); |
|
42 | 42 | } |
43 | 43 | |
44 | - $data["email"] = $request->email; |
|
45 | - return response()->json(['data' => $data, 'state' => true]); |
|
44 | + $data[ "email" ] = $request->email; |
|
45 | + return response()->json([ 'data' => $data, 'state' => true ]); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
@@ -58,26 +58,26 @@ discard block |
||
58 | 58 | $collection = new \MongoDB\Collection($manager, 'builders', 'account'); |
59 | 59 | |
60 | 60 | |
61 | - if ($collection->count(["email" => $email]) == 0) { |
|
62 | - return response()->json(['data' => "User doesn't exist", 'state' => false]); |
|
61 | + if ($collection->count([ "email" => $email ]) == 0) { |
|
62 | + return response()->json([ 'data' => "User doesn't exist", 'state' => false ]); |
|
63 | 63 | } |
64 | 64 | |
65 | - $user = $collection->findOne(["email" => $email])->bsonSerialize(); |
|
65 | + $user = $collection->findOne([ "email" => $email ])->bsonSerialize(); |
|
66 | 66 | |
67 | - if(password_verify($password, $user->password) == false){ |
|
68 | - return response()->json(['data' => "Bad email or password", 'state' => false]); |
|
67 | + if (password_verify($password, $user->password) == false) { |
|
68 | + return response()->json([ 'data' => "Bad email or password", 'state' => false ]); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | $api = new Api($user); |
72 | 72 | Auth::login($api); |
73 | 73 | |
74 | - return response()->json(['data' => $user, 'state' => true]); |
|
74 | + return response()->json([ 'data' => $user, 'state' => true ]); |
|
75 | 75 | |
76 | 76 | } else { |
77 | - return response()->json(['data' => "Invalid parameters", 'state' => false]); |
|
77 | + return response()->json([ 'data' => "Invalid parameters", 'state' => false ]); |
|
78 | 78 | } |
79 | 79 | |
80 | - return response()->json(['data' => "Bad credentials", 'state' => false]); |
|
80 | + return response()->json([ 'data' => "Bad credentials", 'state' => false ]); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | /** |
@@ -89,11 +89,11 @@ discard block |
||
89 | 89 | |
90 | 90 | Auth::logout(); |
91 | 91 | |
92 | - return response()->json(['state' => true]); |
|
92 | + return response()->json([ 'state' => true ]); |
|
93 | 93 | |
94 | 94 | } else { |
95 | 95 | |
96 | - return response()->json(['state' => false]); |
|
96 | + return response()->json([ 'state' => false ]); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | } |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | |
108 | 108 | $items = LaraCart::getItems(); |
109 | 109 | |
110 | - return response()->json(['data' => $items, 'state' => true]); |
|
110 | + return response()->json([ 'data' => $items, 'state' => true ]); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | |
@@ -123,9 +123,9 @@ discard block |
||
123 | 123 | $prix = $request->prix; |
124 | 124 | $options = $request->options; |
125 | 125 | |
126 | - $item = LaraCart::add($id, $title, $quantity, $prix, ['size' => $options ]); |
|
126 | + $item = LaraCart::add($id, $title, $quantity, $prix, [ 'size' => $options ]); |
|
127 | 127 | |
128 | - return response()->json(['data' => $item, 'state' => true]); |
|
128 | + return response()->json([ 'data' => $item, 'state' => true ]); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | |
141 | 141 | $items = LaraCart::getItems(); |
142 | 142 | |
143 | - return response()->json(['data' => $items, 'state' => true]); |
|
143 | + return response()->json([ 'data' => $items, 'state' => true ]); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | |
@@ -149,12 +149,12 @@ discard block |
||
149 | 149 | */ |
150 | 150 | public function getTotalAnnouncesCart() |
151 | 151 | { |
152 | - $data['subtotal'] = LaraCart::subTotal($tax = false, $format = true, $withDiscount = true); |
|
153 | - $data['totaldiscount'] = LaraCart::totalDiscount($formatted = false); |
|
154 | - $data['taxtotal'] = LaraCart::taxTotal($formatted = false); |
|
155 | - $data['total'] = LaraCart::total($formatted = false, $withDiscount = true); |
|
152 | + $data[ 'subtotal' ] = LaraCart::subTotal($tax = false, $format = true, $withDiscount = true); |
|
153 | + $data[ 'totaldiscount' ] = LaraCart::totalDiscount($formatted = false); |
|
154 | + $data[ 'taxtotal' ] = LaraCart::taxTotal($formatted = false); |
|
155 | + $data[ 'total' ] = LaraCart::total($formatted = false, $withDiscount = true); |
|
156 | 156 | |
157 | - return response()->json(['data' => $data, 'state' => true]); |
|
157 | + return response()->json([ 'data' => $data, 'state' => true ]); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | |
@@ -177,16 +177,16 @@ discard block |
||
177 | 177 | |
178 | 178 | if ($auth->attempt($credentials) && auth()->guard('user')->check()) { |
179 | 179 | |
180 | - return response()->json(['data' => auth()->guard('user')->user()->toArray(), 'state' => true]); |
|
180 | + return response()->json([ 'data' => auth()->guard('user')->user()->toArray(), 'state' => true ]); |
|
181 | 181 | } else { |
182 | - return response()->json(['data' => "Bad email or password", 'state' => false]); |
|
182 | + return response()->json([ 'data' => "Bad email or password", 'state' => false ]); |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | } else { |
186 | - return response()->json(['data' => "Invalid parameters", 'state' => false]); |
|
186 | + return response()->json([ 'data' => "Invalid parameters", 'state' => false ]); |
|
187 | 187 | } |
188 | 188 | |
189 | - return response()->json(['data' => "Bad credentials", 'state' => false]); |
|
189 | + return response()->json([ 'data' => "Bad credentials", 'state' => false ]); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | /** |
@@ -199,9 +199,9 @@ discard block |
||
199 | 199 | |
200 | 200 | $result = $collection->find()->toArray(); |
201 | 201 | |
202 | - $tab = []; |
|
203 | - foreach($result as $one){ |
|
204 | - $tab[] = $one->bsonSerialize(); |
|
202 | + $tab = [ ]; |
|
203 | + foreach ($result as $one) { |
|
204 | + $tab[ ] = $one->bsonSerialize(); |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | return response()->json($tab); |
@@ -230,14 +230,14 @@ discard block |
||
230 | 230 | 'created' => new \DateTime("now"), |
231 | 231 | ]; |
232 | 232 | |
233 | - try{ |
|
234 | - $collection->updateOne(["email" => $request->email], $stat); |
|
235 | - }catch (\Exception $e){ |
|
236 | - return response()->json(['state' => false]); |
|
233 | + try { |
|
234 | + $collection->updateOne([ "email" => $request->email ], $stat); |
|
235 | + } catch (\Exception $e) { |
|
236 | + return response()->json([ 'state' => false ]); |
|
237 | 237 | } |
238 | 238 | |
239 | - $data["email"] = $request->email; |
|
240 | - return response()->json(['data' => $data, 'state' => true]); |
|
239 | + $data[ "email" ] = $request->email; |
|
240 | + return response()->json([ 'data' => $data, 'state' => true ]); |
|
241 | 241 | } |
242 | 242 | |
243 | 243 | } |