| 1 |
<?php |
| 2 |
|
| 3 |
namespace Texty\Models; |
| 4 |
|
| 5 |
use Texty\Dependencies\WeDevs\WPKit\DataLayer\DataStore\BaseDataStore; |
| 6 |
|
| 7 |
/** |
| 8 |
* SMS Statistics DataStore |
| 9 |
* |
| 10 |
* Handles all database operations for SMS statistics. |
| 11 |
* |
| 12 |
* @since 2.0.0 |
| 13 |
*/ |
| 14 |
class SmsStatStore extends BaseDataStore { |
| 15 |
|
| 16 |
/** |
| 17 |
* Get the database table name (without prefix) |
| 18 |
* |
| 19 |
* @return string |
| 20 |
* @since 2.0.0 |
| 21 |
*/ |
| 22 |
public function get_table_name(): string { |
| 23 |
return 'texty_sms_stat'; |
| 24 |
} |
| 25 |
|
| 26 |
/** |
| 27 |
* Get field-to-format mapping for wpdb::prepare() |
| 28 |
* |
| 29 |
* @return array |
| 30 |
* @since 2.0.0 |
| 31 |
*/ |
| 32 |
protected function get_fields_with_format(): array { |
| 33 |
return [ |
| 34 |
'receiver' => '%s', |
| 35 |
'gateway' => '%s', |
| 36 |
'status' => '%s', |
| 37 |
'notification_id' => '%s', |
| 38 |
'notification_group' => '%s', |
| 39 |
'message' => '%s', |
| 40 |
'response' => '%s', |
| 41 |
'created_at' => '%s', |
| 42 |
'updated_at' => '%s', |
| 43 |
'reference_id' => '%s', |
| 44 |
]; |
| 45 |
} |
| 46 |
|
| 47 |
/** |
| 48 |
* Get searchable fields for query operations |
| 49 |
* |
| 50 |
* @return array |
| 51 |
* @since 2.0.0 |
| 52 |
*/ |
| 53 |
protected function get_searchable_fields(): array { |
| 54 |
return [ |
| 55 |
'receiver', |
| 56 |
'gateway', |
| 57 |
'reference_id', |
| 58 |
'notification_id', |
| 59 |
'message', |
| 60 |
]; |
| 61 |
} |
| 62 |
|
| 63 |
/** |
| 64 |
* Get the primary key field name |
| 65 |
* |
| 66 |
* @return string |
| 67 |
* @since 2.0.0 |
| 68 |
*/ |
| 69 |
public function get_id_field_name(): string { |
| 70 |
return 'id'; |
| 71 |
} |
| 72 |
|
| 73 |
/** |
| 74 |
* Get the primary key field format |
| 75 |
* |
| 76 |
* @return string |
| 77 |
* @since 2.0.0 |
| 78 |
*/ |
| 79 |
public function get_id_field_format(): string { |
| 80 |
return '%d'; |
| 81 |
} |
| 82 |
|
| 83 |
/** |
| 84 |
* Get date format for specific fields |
| 85 |
* |
| 86 |
* @param string $field Field name |
| 87 |
* |
| 88 |
* @return string PHP date format |
| 89 |
* @since 2.0.0 |
| 90 |
*/ |
| 91 |
public function get_date_format_for_field( string $field ): string { |
| 92 |
return 'Y-m-d H:i:s'; |
| 93 |
} |
| 94 |
} |
| 95 |
|