Lazer\Classes\Helpers\Validate::relation PHP Method

relation() public static method

Checking that relation between tables exists
public static relation ( string $local, string $foreign ) : boolean
$local string local table
$foreign string related table
return boolean relation exists
    public static function relation($local, $foreign)
    {
        $relations = Config::table($local)->relations();
        if (isset($relations->{$foreign})) {
            return TRUE;
        }
        throw new LazerException('Relation "' . $local . '" to "' . $foreign . '" doesn\'t exist');
    }

Usage Example

Esempio n. 1
0
 /**
  * Use relation to table
  * @param string $table Table name
  * @return \Lazer\Classes\Core_Relation
  */
 public function with($table)
 {
     Validate::relation($this->tables['local'], $table);
     $this->setTable('foreign', $table);
     $this->setRelationType(Config::table($this->tables['local'])->relations($this->tables['foreign'])->type);
     $this->setKey('local', Config::table($this->tables['local'])->relations($this->tables['foreign'])->keys->local);
     $this->setKey('foreign', Config::table($this->tables['local'])->relations($this->tables['foreign'])->keys->foreign);
     return $this;
 }
All Usage Examples Of Lazer\Classes\Helpers\Validate::relation