3
3
namespace App \Http \Controllers \API ;
4
4
5
5
use Illuminate \Http \Request ;
6
- use App \ Http \ Controllers \Controller ;
6
+ use Illuminate \ Routing \Controller ;
7
7
use App \Models \Gateway ;
8
8
use Validator ;
9
9
@@ -26,27 +26,27 @@ public function ping(Request $request)
26
26
'sys_load ' => 'required|numeric ' ,
27
27
'wifidog_uptime ' => 'required|integer ' ,
28
28
]);
29
- $ r = 'Error: params wrong ' ;
29
+ $ responseTxt = 'Error: params wrong ' ;
30
30
if ($ validator ->fails ()) {
31
- return response ()->txt ($ r , 400 );
31
+ return response ()->txt ($ responseTxt , 400 );
32
32
}
33
33
$ input = $ validator ->getData ();
34
34
$ input ['id ' ] = $ input ['gw_id ' ];
35
35
unset($ input ['gw_id ' ]);
36
- $ status_code = 200 ;
36
+ $ statusCode = 200 ;
37
37
if (config ('wifidog.allow_unknown_gateway ' )) {
38
38
Gateway::updateOrCreate (['id ' => $ input ['id ' ]], $ input );
39
- $ r = 'Pong ' ;
40
- } else {
41
- $ gw = Gateway::find ($ input ['id ' ]);
42
- if (!empty ($ gw )) {
43
- $ gw ->update ($ input );
44
- $ r = 'Pong ' ;
45
- } else {
46
- $ r = 'Error: not allow unknown gateway ' ;
47
- $ status_code = 400 ;
48
- }
39
+ $ responseTxt = 'Pong ' ;
40
+ return response ()->txt ($ responseTxt , $ statusCode );
49
41
}
50
- return response ()->txt ($ r , $ status_code );
42
+ $ gateway = Gateway::find ($ input ['id ' ]);
43
+ if (!empty ($ gateway )) {
44
+ $ gateway ->update ($ input );
45
+ $ responseTxt = 'Pong ' ;
46
+ return response ()->txt ($ responseTxt , $ statusCode );
47
+ }
48
+ $ responseTxt = 'Error: not allow unknown gateway ' ;
49
+ $ statusCode = 400 ;
50
+ return response ()->txt ($ responseTxt , $ statusCode );
51
51
}
52
52
}
0 commit comments