where('statements_id', $item['statements_id']) ->where('order_month', $item['order_month'])->where('project_name', $item['project_name'])->first(); if(empty($model)) { $model = new self(); } $model->enable = 1; $model->statements_id = $item['statements_id']; $model->project_name = $item['project_name']; $model->order_month = $item['order_month']; $model->order_amount = $item['order_amount']; $model->saler = $item['saler']; $model->handler = $item['handler']; $model->save(); } } public static function updateData() { } public static function getDataBySearch($search) { $statementsFileDetailModel = self::query()->where('enable', 1); if(isset($search['order_month_start']) && !empty($search['order_month_start'])) { $statementsFileDetailModel->where('order_month', '>=', date('Y-m-01', strtotime($search['order_month_start']))); } if(isset($search['order_month_end']) && !empty($search['order_month_end'])) { $statementsFileDetailModel->where('order_month', '<=', date('Y-m-01', strtotime($search['order_month_end']))); } if(isset($search['project_name']) && !empty($search['project_name'])) { $statementsFileDetailModel->where('project_name', 'like', '%'.$search['project_name'].'%'); } if(isset($search['statements_id']) && !empty($search['statements_id'])) { $statementsFileDetailModel->where('statements_id', $search['statements_id']); } if(isset($search['statements_id_list']) && !empty($search['statements_id_list'])) { $statementsFileDetailModel->whereIn('statements_id', $search['statements_id_list']); } return $statementsFileDetailModel; } }