addRef() public method

Add generic relation. Provide your own call-back that will return the model.
public addRef ( string $link, array $callback ) : object
$link string Link
$callback array Callback
return object
Example #1
0
 public function testCustomRef()
 {
     $a = [];
     $p = new \atk4\data\Persistence_Array($a);
     $m = new Model($p, ['table' => 'user']);
     $m->addRef('archive', function ($m) {
         return $m->newInstance(null, ['table' => $m->table . '_archive']);
     });
     $this->assertEquals('user_archive', $m->ref('archive')->table);
 }