ฉันสงสัยว่าเหตุใดฉันจึงไม่สามารถกู้คืนข้อมูลที่ถูกลบแบบนุ่มนวลใน laravel ได้ ฉันทำทุกอย่างถูกต้องแล้ว แต่ไม่แน่ใจว่าขาดอะไรไป ดังนั้นฉันจึงไม่สามารถกู้คืนข้อมูลได้
นางแบบของฉันคือ
namespace App\Model\Clients;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class SocialAccounts extends Model{
protected $table = 'social_accounts';
use SoftDeletes;
protected $dates = ['deleted_at'];
}
ฉันใช้คุณสมบัติการลบแบบนุ่มนวล สำหรับการกู้คืนข้อมูลที่ถูกลบของฉัน ฉันกำลังดำเนินการดังนี้
$restoreAccount = SocialAccounts::withTrashed()->find($id)->restore();
แต่มันไม่ได้กู้คืนข้อมูล ฉันคิดว่าเมื่อเรากู้คืนข้อมูล laravel NULL คอลัมน์ที่ถูกลบ แต่ไม่ได้อัปเดตอะไรเลยใน id นั้น
ฉันยังได้ลอง
//second alternate method
$restoreAccount= SocialAccounts::withTrashed()->find($id)->update(['deleted_at' => NULL]);
//Third alternate method
$restoreAccount = SocialAccounts::withTrashed()->find($id);
$restoreAccount->deleted_at = NULL;
$restoreAccount->save();
ฉันไม่แน่ใจว่าฉันทำอะไรผิด มีอะไรที่เราต้องทำเพื่อให้ได้รับการกู้คืนหรือไม่ ฉันตรวจสอบเอกสาร laravel อย่างเป็นทางการแล้วติดตามสิ่งเดียวกัน