<?php

namespace Hura8\Components\User\Model;


use Hura8\Interfaces\AppResponse;
use Hura8\System\Model\aEntityBaseModel;
use Hura8\Interfaces\iEntityModel;
use Hura8\Interfaces\EntityType;


class UserContactModel extends aEntityBaseModel implements iEntityModel
{

    public function __construct() {
        parent::__construct(EntityType::USER_CONTACT);
    }


    protected function extendedFilterOptions() : array
    {
        return [
            // empty for now
        ];
    }


    protected function _buildQueryConditionExtend(array $condition) : ?array
    {
        /*$condition = array(
            "q" => "",
            "status" => 0,
            'read' => 1,-1
        );*/

        $catCondition = [];
        $bind_types = [];
        $bind_values = [];

        if(isset($condition["read"]) && $condition["read"]){
            $catCondition[] = " AND `is_read` = ?  ";
            $bind_types[] = 'd';
            $bind_values[] = ($condition["read"] ==  1) ? 1 : 0;
        }

        return array( join(" ", $catCondition), $bind_types, $bind_values);
    }

    protected function _buildQueryOrderBy($sort_by = "new")
    {
        return parent::_buildQueryOrderBy($sort_by);
    }

}
