<?php


namespace app\model;

use DateTimeInterface;
use Illuminate\Database\Eloquent\Casts\Attribute;
use support\Model;

class MarketCustomerFollow extends Model
{
    protected $table = 'market_customer_follow';

    protected $dateFormat = 'U';

    public function serializeDate(DateTimeInterface $date)
    {
        return $date->format('Y-m-d H:i:s');
    }

    protected function followTime():Attribute
    {
        return Attribute::get(function ($value) {
            return date('Y-m-d H:i:s', $value);
        });
    }

    public function custom()
    {
        return $this->belongsTo(MarketCustomer::class, 'market_customer_id');
    }

    public function consultant()
    {
        return $this->belongsTo(Consultant::class, 'consultant_id');
    }
}