. */ /** * An interface to the payment table in the database */ class Payment extends Model { public $table = 'payment', $fillable_columns = ['offerId', 'date']; /** * Get the offer that this payment is linked to * * @return offer The offer */ public function getOffer() { return new Offer($this->pdo, $this->offerId); } protected function accessor($key, $value) { switch ($key) { case 'date': return strtotime($value); break; default: return parent::accessor($key, $value); } } protected function mutator($key, $value) { switch ($key) { case 'date': return is_string($value) ? $value : date('Y-m-d H:i:s', $value); break; default: return parent::mutator($key, $value); } } }