<?php

class Scopes extends \Phalcon\Mvc\Model
{
    /**
     * Initialize method for model.
     */
    public function initialize()
    {
        $this->setSchema("jaga");
        $this->setSource("scopes");
        $this->belongsTo('id', 'RolesScopes', 'scope_id');
        $this->hasManyToMany(
            'id',
            'RolesScopes',
            'scope_id',
            'role_id',
            'Roles',
            'id'
        );
    }

    /**
     * Returns table name mapped in the model.
     *
     * @return string
     */
    public function getSource()
    {
        return 'scopes';
    }

    
    public function toDetail()
    {
        $result = $this->toArray();

        $result['aksi_list'] = $this->roles;
        
        return $result;
    }
}
