<?php
namespace WpBookingProAdmin\app\models;
defined('_WPBOOKINGPRO_EXEC') or die;

use WpBookingPro\Factory;
use WpBookingPro\Mvc\Model\ModelForm;
use WpBookingPro\Form\Form;
use WpBookingPro\Mvc\Model\ModelList;
use WpBookingPro\Registry\Registry;
class UsersModel extends ModelList
{
    /**
     * @var string
     */
    public $context = "users";
    /**
     * @var string
     */
    public $table_name = "user";

    public function getList()
    {
        include(ABSPATH . "wp-includes/pluggable.php");
        $list_user =  parent::getList(); // TODO: Change the autogenerated stub
        $db = Factory::getDBO();
        $query = $db->getQuery(true);
        foreach ($list_user as &$user) {
            $query->clear()
                ->select('name')
                ->from($this->getTableName('groupuser'))
                ->where('id='.(int)$user->group_user_id)
            ;
            $user->group_name = $db->setQuery($query)->loadResult();
            $user_wordpress = get_userdata($user->open_source_user_id);
            $user->user_wordpress = $user_wordpress;

        }
        return $list_user;
    }


}
