<?php
/**
 * @package     DOCman
 * @copyright   Copyright (C) 2019 Timble CVBA. (http://www.timble.net)
 * @license     GNU GPLv3 <http://www.gnu.org/licenses/gpl.html>
 * @link        http://www.joomlatools.com
 */

namespace Foliolabs\Docman;

use Foliolabs\Library;

class ModelEntityUser extends Library\ModelEntityRow
{
    public function delete()
    {
        $result = parent::delete();

        if ($result)
        {
            $query = $this->getObject('lib:database.query.delete')
                          ->table('docman_categories_permissions')
                          ->where('wp_user_id = :user')
                          ->bind(['user' => $this->id]);

            $this->getTable()->getDriver()->delete($query);
        }

        return $result;
    }
}