繁体   English   中英

Laravel SoftDeletes 与 UpdateOrCreate 函数冲突

[英]Laravel SoftDeletes conflict with UpdateOrCreate Function

我的 updateOrCreate 函数产生此错误

[Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Invalid column name 'deleted_at'.

当我实施

use SoftDeletes;

列名“deleted_at”存在于我的表数据库中,我尝试将其添加到可填写文件中,但它仍然不起作用,而且似乎我在网上找不到类似的问题。

我的 updateOrCreate 函数

Employee::updateOrCreate(['eeno' => $eeno],
            [
                'eeno' => $eeno,
                'name' => $name,
                'originally_hired' => $originally_hired,
                'date_hired' => $date_hired,
                'regularization_date' => $regularization_date,
                'birth_date' => $birth_date,
                'age' => floor(number_format($age, 2)),
                'position_id' => $position_id,
                'job_id' => $job_id,
                'employee_status_id' => $employment_status_id,
                'section_id' => $section_id,
                'department_id' => $department_id,
                'division_id' => $division_id,
                'area_id' => $area_id,
                'head_eeno' => $head_eeno,
//                'rate' => $rate,
//                'position_allowance' => $position_allowance,
                'rcc' => $rcc,
                'business_unit' => $business_unit,
                'civil_status' => $civil_status,
                'tax_code' => $tax_code,
                'gender' => $gender,
                'educational_attainment' => $educational_attainment,
                'school' => $school,
                'license' => $licensure,
                'post_graduate' => $post_graduate,
                'post_graduate_school' => $post_graduate_school,
                'religion' => $religion,
                'tin_no' => $tin_no,
                'phil_health_no' => $philhealth_no,
                'hdmf' => $hdmf,
                'sss_no' => $sss_no,
                'address' => $address,
                'remarks' => $remarks
            ]

我的员工模型

namespace App;

use Carbon\Carbon;
use Exception;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Storage;
use Yajra\DataTables\Facades\DataTables;
use Illuminate\Support\Facades\Gate;
use Illuminate\Validation\ValidationException;

class Employee extends Model
{

    use SoftDeletes;

    protected $fillable = [
        'eeno','name','originally_hired','date_hired','regularization_date','birth_date','age','position_id',
        'job_id','employee_status_id','rate','position_allowance','rcc','business_unit','section_id',
        'department_id','division_id','area_id','head_eeno','civil_status','tax_code','gender','educational_attainment',
        'school','license','post_graduate','religion','tin_no','phil_health_no','hdmf','sss_no','vmc_cares_membership',
        'address','picture','post_graduate_school','remarks'
    ];

    protected $table = 'employee';
}

您需要通过创建表的迁移文件或另一个修改它的迁移文件将delete_at列添加到迁移中:

$table->softDeletes();

https://laravel.com/docs/master/eloquent#soft-deleting

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM