0
我需要你的幫助,刪除不起作用。雄辯刪除不起作用
public function postUnregisterPushNotifications()
{
try {
$serial_usr = JWTAuth::getPayload(JWTAuth::getToken())->get('sub');
$device_token = Input::get('device_token');
\t \t \t $topic = null;
$device = Device::where('user_id', $serial_usr)->where('token', $device_token);
$device-> delete();
JWTAuth::setToken(JWTAuth::getToken())->invalidate();
return ws_response(false, 'Unregister Notification success', '', 200);
} catch (Exception $ex) {
return ws_response(true, null, 'ERROR ' . $ex->getCode() . '! ' . $ex->getMessage(), 500);
}
}
插入表中的作品,但是當我註銷不會從表中刪除刪除
需要一些更多的背景在這裏。你是否已經逐步瞭解'$ device'是否可以從數據庫中正確提取?你有錯誤信息嗎? – mopo922
'dd($ device);'看它是否真的從db中獲取 –
我認爲你缺少'$ device = Device :: where('user_id',$ serial_usr)上的get() ('token',$ device_token);'應該是'$ device = Device :: where('user_id',$ serial_usr) - > where('token',$ device_token) - > get();'so it可以返回一些東西,否則只是一個雄辯的召喚,而不是對象本身。 – Lvkz