<?php

namespace Hura8\Components\User\Model;

use Hura8\Components\Customer\PublicController\UCustomerLoginController;
use Hura8\Components\Staff\PublicController\StaffLoginController;
use Hura8\Interfaces\AppResponse;
use Hura8\Interfaces\iEntityModel;
use Hura8\System\Model\aEntityBaseModel;

class UserUploadModel extends aEntityBaseModel implements iEntityModel
{

    protected $web_user_id  = '';
    protected $customer_id  = 0;
    protected $item_type    = '';
    protected $item_id      = '';


    public function __construct($web_user_id, $customer_id, $item_type='', $item_id=0) {
        parent::__construct('user_upload');

        $this->web_user_id  = $web_user_id;
        $this->customer_id  = $customer_id;
        $this->item_id      = $item_id;
        $this->item_type    = $item_type;
    }

    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["type"]) && $condition["type"]){
            $catCondition[] = " AND `type` = ?  ";
            $bind_types[] = 's';
            $bind_values[] = $condition["type"];
        }

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

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

}
