This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

Alexandre
Alexandre

Each definition is an array where the key is the relation name and the value is a detail array.

i have 2 Models:

  • Professor
  • Programa

above summarized code

// Professor model class
protected $table = 'professor';

public $hasMany = [
  'programa' => ['Author\Plugin\Models\Programa']
];

// Programa model class (look at relation name)
protected $table = 'programa';

public $belongsTo = [
  'professor' => ['Author\Plugin\Models\Professor']
];

i can normally access

{{ programa.professor }}  // all right, returning one model

but if i change the relation name in Programa, for example

public $belongsTo = [
  'coordenador' => ['Author\Plugin\Models\Professor']
];

when i try access

{{ programa.coordenador }} // returning null

am curious for the reason that's happening because i did the same with others relation name in these models and worked fine

1-1 of 1

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.