Hello
Model Reports
<?php
namespace Sample\Models;
use Phalcon\Mvc\Model;
class Reports extends Model {
public $id; public $user_id; public function initialize(){ $this->belongsTo('user_id', 'Sample\Models\Users'); $this->belongsTo('government_agency_id', 'Sample\Models\GovernmentAgencies', 'id'); }
}
Model Users
<?php namespace Sample\Models;
use Phalcon\Mvc\Model;
public $id;
public $user_id;
class Users extends Model {
public $id; public function initialize(){ $this->hasMany('id', 'Sample\Models\Reports', 'user_id'); }
}
Hello guys , Phalcon BelongsTo relationship is not working
when I fetch a Reports and try to get his Users - object returning null
$reports = Reports::findFirst(); echo $reports->Users->id;
$this->response->setJsonContent($reports->Users->id); return $this->response;
DISPLAY
NULL