We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Problems with ManyToMany Relation in namespaces

Booking model:

namespace TLH\Models;
class Booking extends \Phalcon\Mvc\Model{
    public function initialize(){

        //define relations
            "Booking", "Customer",
        $this->belongsTo("Route","TLH\Models\Route","Id", array("alias" => "RouteInfo"));

ManyToMany Entity

 namespace TLH\Models;
 class BookingCustomer extends \Phalcon\Mvc\Model{

    public $Booking;
    public $Customer;
    public $CustomerType;

    public function initialize(){


        //define relations column, entity, id
        $this->belongsTo("Booking", "TLH\Models\Booking", "Id");
        $this->belongsTo("Customer", "TLH\Models\Customer", "Id");


I am geting this error:

 The method "CustomerInfo" doesn't exist on model "TLH\Models\Booking"


 The method "getCustomerInfo" doesn't exist on model "TLH\Models\Booking"



Solved by adding alias:

array('alias' => 'CustomerInfo') 
//to many to many realtion

Phalcon rocks.