mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-07-27 23:27:04 -04:00
- made updated_at and deleted_at to be nullable - Add getter for mailchimpId - Changed primaryKey to customer_id so that baseModel functions could be used natively rather than writing custom code. - Removed unneeded getByCustomerId() since BaseModel->find() can be used now. Signed-off-by: objec <objecttothis@gmail.com>
35 lines
1.2 KiB
PHP
35 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Plugins\MailchimpPlugin\Entities;
|
|
|
|
use CodeIgniter\Entity\Entity;
|
|
|
|
class Subscription extends Entity
|
|
{
|
|
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
|
|
protected $casts = [
|
|
'customer_id' => 'integer',
|
|
'mailchimp_id' => 'string',
|
|
'status_id' => 'enum[App\Plugins\MailchimpPlugin\Enums\SubscriptionStatus]',
|
|
'created_at' => 'datetime',
|
|
'updated_at' => '?datetime',
|
|
'deleted_at' => '?datetime'
|
|
];
|
|
|
|
protected $attributes = [
|
|
'customer_id' => null, // ospos_customers.person_id
|
|
'mailchimp_id' => null, // MD5 hash of the lowercase version of the list member's email address
|
|
'status_id' => null, // ospos_mailchimpplugin_subscription_status.status_id
|
|
'created_at' => null, // Timestamp of when the subscription was created
|
|
'updated_at' => null, // Timestamp of when the subscription was last updated
|
|
'deleted_at' => null // Timestamp of when the subscription was deleted
|
|
];
|
|
|
|
public function setMailchimpId(string $email)
|
|
{
|
|
$this->attributes['mailchimp_id'] = md5(strtolower($email));
|
|
|
|
return $this;
|
|
}
|
|
}
|