T
T
The-TS2020-10-25 21:30:29
Laravel
The-TS, 2020-10-25 21:30:29

Can't recover a deleted record through soft deletion?

Here is the error report in frame 44, app/Http/Controllers/service/DB_controller.php

Model UsersDB.php :

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class UsersDB extends Model
{
    use SoftDeletes;
    use HasFactory;

    protected $dates = ['deleted_at'];
    protected $table = 'users_d_b_s';
    protected $guarded = ['id']; //<== Нет проблема не в этой строке, вроде...
}

Database:
Structure:
Gf5jw1I.png
Overview:
wKV1MZx.png

Thank you!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Ukolov, 2020-10-25
@Pyhon3x

where(['id' => '1'])

P
pLavrenov, 2020-10-27
@pLavrenov

Uuhhh..
1) delete protected $dates , because use SoftDeletes already assumes that the deleted_at field is a date.
2) UsersDB::withTrashed()->find($id)->restore();
3) Incorrect where construction

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question