【发布时间】:2021-08-25 04:07:14
【问题描述】:
我的 Laravel Excel 导入中有一个构造函数来节省资源。
public function __construct()
{
$this->employees = EmployeeInformation::where('company_id', Auth::user()
->company_id)
->select('id', 'employee_number')->get();
}
我面临的问题是,当我使用$this->employees 获取第一条记录时,它是否区分大小写。例如Employee Number 是 EMP1
这会返回员工。
$this->employees->where('employee_number', 'EMP1')->first();
这将返回 null。
$this->employees->where('employee_number', 'emp1')->first();
有什么办法可以节省资源吗?我想要实现的是使用$this->employees 搜索员工的记录,以避免在我的导入中查询每行。
【问题讨论】:
标签: php mysql laravel eloquent