public function destroy($deviceId)
 {
     $device = User::find(Auth::user()->id)->devices()->where('devices.id', '=', $deviceId)->whereNull('devices.deleted_at')->first();
     if (is_null($note)) {
         return EndorphinHelpers::apiResponse(EndorphinHelpers::STATUS_NOTFOUND, array('item' => 'device', 'id' => $deviceId));
     }
     $deletedDevice = $device;
     $device->delete();
     return EndorphinHelpers::apiResponse(EndorphinHelpers::STATUS_SUCCESS, $device);
 }
 public function beat()
 {
     $data = Input::all();
     // return EndorphinHelpers::apiResponse(EndorphinHelpers::STATUS_SUCCESS, $data['data']);
     if (is_null($data)) {
         return EndorphinHelpers::apiResponse(EndorphinHelpers::STATUS_ERROR, array('item' => 'data'));
     }
     if (is_null($data['phone_imei'])) {
         return EndorphinHelpers::apiResponse(EndorphinHelpers::STATUS_ERROR, array('item' => 'phone_imei'));
     }
     $heartbeat = new Heartbeat($data);
     $heartbeat->save();
     $device = Device::with(array('users' => function ($query) {
         $query->where('device_user.user_id', '=', Auth::user()->id);
     }, 'heartbeats' => function ($query) {
     }))->where('hardware_id', '=', $data['phone_imei'])->whereNull('deleted_at')->get();
     if (is_null($device)) {
         $device = new Device(array('name' => $data['phone_imei'], 'hardware_id' => $data['phone_imei']));
         $device->save();
     }
     $device->heartbeats()->attach($heartbeat);
     return EndorphinHelpers::apiResponse(EndorphinHelpers::STATUS_SUCCESS, $device);
 }
Example #3
0
 public function show($translation)
 {
     return EndorphinHelpers::apiResponse(EndorphinHelpers::STATUS_SUCCESS, Lang::get($translation));
 }