for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* Bluz Framework Component
*
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
declare(strict_types=1);
namespace Bluz\Db\Traits;
use Bluz\Db\Relations;
* TableRelations
* @package Bluz\Db\Traits
* @author Anton Shevchuk
trait TableRelations
{
* Setup relation "one to one" or "one to many"
* @param string $key
* @param string $model
* @param string $foreign
* @return void
public function linkTo($key, $model, $foreign) : void
Relations::setRelation($this->model, $key, $model, $foreign);
model
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
class MyClass { } $x = new MyClass(); $x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:
class MyClass { public $foo; } $x = new MyClass(); $x->foo = true;
}
* Setup relation "many to many"
* [table1-key] [table1_key-table2-table3_key] [table3-key]
* @param string $link
public function linkToMany($model, $link) : void
Relations::setRelations($this->model, $model, [$link]);
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: