order relation results in Models

For example my project has parts, the initialize function of my project model looks like this:

    /**
     * Initialize method for model.
     */
    public function initialize()
    {
        $this->hasMany("id", "Parts", "project_id", array("alias" => "Parts"));
        $this->belongsTo("creator_id", "Users", "id", NULL);
        $this->hasManyToMany(
            "id",
            "ProjectHasEmployees",
            "project_id", "employee_id",
            "Users",
            "id",
            array("alias" => "employees")
        );
        $this->belongsTo("type_id", "ProjectType", "id", array("alias" => "type"));
    }

I want to order the hasMany relation of my project model.

The documentation shows this:

public Phalcon\Mvc\Model\Relation belongsTo (mixed $fields, string $referenceModel, mixed $referencedFields, [array $options])

How can I tell what the options are? The last parameter. Multiple times in the documentation i see an parameter like [array $options], how can I tell what options I can put in? Is there an option to set the order by of my relationsships like hasMany,belongsTo etc? And also can I RESTfully change the order an parameter like /orderby/part_priority



83.4k

There's no option to define an order there in the relation definition, you can pass that parameter when retreiving the related records:

$employees = $project->getEmployees(["order" => "name"])

Thanks, another question: How or where can I see what options are available? In the documentation of phalcon