Bluz\Db\Relations::setRelations PHP Method

setRelations() public static method

Setup multi relations
public static setRelations ( string $modelOne, string $modelTwo, array $relations ) : void
$modelOne string
$modelTwo string
$relations array
return void
    public static function setRelations($modelOne, $modelTwo, $relations)
    {
        $name = [$modelOne, $modelTwo];
        sort($name);
        $name = join(':', $name);
        // create record in static variable
        self::$relations[$name] = $relations;
    }

Usage Example

Example #1
0
 /**
  * Setup relation "many to many"
  * [table1-key] [table1_key-table2-table3_key] [table3-key]
  *
  * @param  string $model
  * @param  string $link
  * @return void
  */
 public function linkToMany($model, $link)
 {
     Relations::setRelations($this->model, $model, [$link]);
 }