<?php

namespace Booktics\Models;

use Booktics\Abstracts\Booktics_Database;
use Booktics\Abstracts\User_Model;

class Customer_Model extends User_Model {
    /**
     * Store specific user role
     *
     * @var string
     */
    protected $role = 'booktics_customer';

    /**
     * Store specific meta prefix
     *
     * @var string
     */
    protected $meta_prefix = '_customer_';

    /**
     * Store user data
     *
     * @var array
     */
    protected $fillable = [
        'id'              => '',
        'display_name'    => '',
        'first_name'      => '',
        'last_name'       => '',
        'user_email'      => '',
        'image'           => '',
        'user_login'      => '',
        'phone'           => '',
        'role'            => [],
        'status'          => '',
        'user_registered' => '',
        'total_booking'   => '',
        'total_amount'    => '',
    ];

    /**
     * Display name attribute
     *
     * @param $customer
     *
     * @return string
     */
    public function get_display_name_attribute( $customer ) {
        return $customer->first_name . ' ' . $customer->last_name;
    }

    /**
     * email attribute
     *
     * @param $customer
     *
     * @return string
     */
    public function get_email_attribute( $customer ) {
        return $customer->email ?? $customer->user_email;
    }
}