@@ -26,13 +26,13 @@ discard block |
||
| 26 | 26 | public function show($device_id) |
| 27 | 27 | { |
| 28 | 28 | $storagePath = storage_path('app/images/devices/'); |
| 29 | - $imagePath = glob($storagePath . $device_id . "*" . ".jpg"); |
|
| 29 | + $imagePath = glob($storagePath.$device_id."*".".jpg"); |
|
| 30 | 30 | |
| 31 | 31 | if (!empty($imagePath)) |
| 32 | - $image = Image::make($imagePath[0]); |
|
| 32 | + $image = Image::make($imagePath[ 0 ]); |
|
| 33 | 33 | else |
| 34 | 34 | { |
| 35 | - $imagePath = public_path() . '/img/video_not_found.jpg'; |
|
| 35 | + $imagePath = public_path().'/img/video_not_found.jpg'; |
|
| 36 | 36 | $image = Image::make($imagePath); |
| 37 | 37 | } |
| 38 | 38 | |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | */ |
| 49 | 49 | public function store($device_id, $binaryData) |
| 50 | 50 | { |
| 51 | - $storagePath = storage_path('app/images/devices/') . $device_id . '.jpg'; |
|
| 51 | + $storagePath = storage_path('app/images/devices/').$device_id.'.jpg'; |
|
| 52 | 52 | $image = Image::make($binaryData); |
| 53 | 53 | $image->save($storagePath, 75); |
| 54 | 54 | } |
@@ -55,9 +55,9 @@ |
||
| 55 | 55 | */ |
| 56 | 56 | public function orderedSiteLocationsBy($site_id, $location_id) |
| 57 | 57 | { |
| 58 | - $locations = self::query()->select(['id', 'name']) |
|
| 58 | + $locations = self::query()->select([ 'id', 'name' ]) |
|
| 59 | 59 | ->where('site_id', '=', $site_id) |
| 60 | - ->orderByRaw(DB::raw("(id = " . $location_id . ") DESC")) |
|
| 60 | + ->orderByRaw(DB::raw("(id = ".$location_id.") DESC")) |
|
| 61 | 61 | ->get(); |
| 62 | 62 | return $locations; |
| 63 | 63 | } |
@@ -42,8 +42,8 @@ |
||
| 42 | 42 | */ |
| 43 | 43 | public function orderedSitesBy($id) |
| 44 | 44 | { |
| 45 | - $sites = self::query()->select(['id', 'name']) |
|
| 46 | - ->orderByRaw(DB::raw("(id = " . $id . ") DESC")) |
|
| 45 | + $sites = self::query()->select([ 'id', 'name' ]) |
|
| 46 | + ->orderByRaw(DB::raw("(id = ".$id.") DESC")) |
|
| 47 | 47 | ->get(); |
| 48 | 48 | return $sites; |
| 49 | 49 | } |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | /** |
| 12 | 12 | * Creates a json response for all the devices. |
| 13 | 13 | * |
| 14 | - * @return Response |
|
| 14 | + * @return \Illuminate\Http\JsonResponse |
|
| 15 | 15 | */ |
| 16 | 16 | public function index() |
| 17 | 17 | { |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | * Creates a json response for a specifc device. |
| 24 | 24 | * |
| 25 | 25 | * @param Device $device |
| 26 | - * @return Response |
|
| 26 | + * @return \Illuminate\Http\JsonResponse |
|
| 27 | 27 | */ |
| 28 | 28 | public function show(Device $device) |
| 29 | 29 | { |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | * Updates the status of a device. |
| 35 | 35 | * |
| 36 | 36 | * @param Request $request |
| 37 | - * @return Response |
|
| 37 | + * @return \Illuminate\Http\JsonResponse |
|
| 38 | 38 | */ |
| 39 | 39 | public function update(Request $request) |
| 40 | 40 | { |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | * Registers a new device. |
| 106 | 106 | * |
| 107 | 107 | * @param Request $request |
| 108 | - * @return Response |
|
| 108 | + * @return \Illuminate\Http\JsonResponse |
|
| 109 | 109 | */ |
| 110 | 110 | public function register(Request $request) |
| 111 | 111 | { |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | |
| 61 | 61 | // If validation fails, send the validation error back with status 400 |
| 62 | 62 | if ($validator->fails()) { |
| 63 | - return response()->json(['data' => $validator->toArray()], 400); |
|
| 63 | + return response()->json([ 'data' => $validator->toArray() ], 400); |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | // Get the device record |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | |
| 69 | 69 | // If token doesnt match then send 401 unauthorized. |
| 70 | 70 | if ($request->input('token') != $device->token) { |
| 71 | - return response()->json(['data' => 'Bad token.'], 401); |
|
| 71 | + return response()->json([ 'data' => 'Bad token.' ], 401); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | // Update the device |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | //event(new Registered(true)); |
| 99 | 99 | |
| 100 | 100 | // Return the new device info including the token. |
| 101 | - return response()->json(['data' => $device->toArray()], 201); |
|
| 101 | + return response()->json([ 'data' => $device->toArray() ], 201); |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | /** |
@@ -117,12 +117,12 @@ discard block |
||
| 117 | 117 | |
| 118 | 118 | // If validation fails, send the validation error back with status 400 |
| 119 | 119 | if ($validator->fails()) { |
| 120 | - return response()->json(['data' => $validator->toArray()], 400); |
|
| 120 | + return response()->json([ 'data' => $validator->toArray() ], 400); |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | // If challenge string doesnt match then send 401 unauthorized. |
| 124 | 124 | if ($request->input('challenge') != 'temppass') { |
| 125 | - return response()->json(['data' => 'Bad challenge.'], 401); |
|
| 125 | + return response()->json([ 'data' => 'Bad challenge.' ], 401); |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | // If the uuid already exists then just send them the record. |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | 'uuid' => $device->uuid, |
| 133 | 133 | 'id' => $device->id, |
| 134 | 134 | 'token' => $device->token, |
| 135 | - ]], 200); |
|
| 135 | + ] ], 200); |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | // Create the new device |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | 'uuid' => $device->uuid, |
| 156 | 156 | 'id' => $device->id, |
| 157 | 157 | 'token' => $device->token, |
| 158 | - ]], 201); |
|
| 158 | + ] ], 201); |
|
| 159 | 159 | } |
| 160 | 160 | } |
| 161 | 161 | |
@@ -24,7 +24,7 @@ |
||
| 24 | 24 | * |
| 25 | 25 | * @var array |
| 26 | 26 | */ |
| 27 | - protected $hidden = ['token']; |
|
| 27 | + protected $hidden = [ 'token' ]; |
|
| 28 | 28 | |
| 29 | 29 | /** |
| 30 | 30 | * The attributes that are mass assignable. |