'required|min_length[3]', // 'email' => 'permit_empty|valid_email|is_unique[partner_pos.email,id,{id}]', // 'mobile' => 'permit_empty|numeric|max_length[20]|is_unique[partner_pos.mobile,id,{id}]', // 'manager_id' => 'required|integer', // ]; // protected $validationMessages = [ // 'email' => [ // 'is_unique' => 'Sorry, that email address is already registered.', // ], // ]; /** * @var bool Whether to skip validation during inserts and updates. */ protected $skipValidation = false; /** * @var bool Whether to clean data for SQL Injection. */ protected $cleanValidationRules = true; protected $beforeInsert = ["checkAndADDCreatedByValue"]; protected $beforeUpdate = ["checkAndUpdateUpdatedByValue"]; protected function checkAndADDCreatedByValue(array $data) { // Check if 'updated_by' value is null or empty if (empty($data['data']['created_by'])) { // Set 'updated_by' value to the current session user ID $data['data']['created_by'] = get_session_userid(); } return $data; } protected function checkAndUpdateUpdatedByValue(array $data) { // Check if 'updated_by' value is null or empty if (empty($data['data']['updated_by'])) { // Set 'updated_by' value to the current session user ID $data['data']['updated_by'] = get_session_userid(); } return $data; } }