/** * @author Thuanth6589 <*****@*****.**> * @param array $data * @return bool * @throws \Exception */ public function save_data() { $data = $this->fields; if (empty($data)) { return false; } $data['updated_at'] = date('Y-m-d H:i:s', time()); if (!isset($data['ss_id'])) { $data['created_at'] = date('Y-m-d H:i:s', time()); $data['is_available'] = 0; $ss = Model_Mss::forge(); } else { $ss = Model_Mss::find_by_pk($data['ss_id']); if (!isset($ss)) { return false; } $ss->is_new(false); } $ss->set($data); if ($ss->save()) { return true; } return false; }
public static function find_ss_list($object, $flag = false) { $model_ss = new Model_Mss(); $model_partner = new Model_Mpartner(); $list_partner_code = array(); if ($flag) { $list_partner = \Model_Mpartner::forge()->find($object); } else { $list_partner = $model_partner->get_info_by_userid($object); } $list_ss_id = array(); foreach ($list_partner as $item) { $list_partner_code[] = $item['partner_code']; } if ($list_partner_code) { $config_partner['where'][] = array('partner_code', 'IN', $list_partner_code); $list_ss = \Model_Mss::forge()->find($config_partner); if ($list_ss) { foreach ($list_ss as $key => $val) { $list_ss_id[] = $val->ss_id; } } } return $list_ss_id; }