Beispiel #1
0
 /**
  * Checking that relation type is correct
  * @param string $type 
  * @return bool relation type
  * @throws LazerException Wrong relation type
  */
 public static function relationType($type)
 {
     if (in_array($type, Relation::relations())) {
         return true;
     }
     throw new LazerException('Wrong relation type');
 }
Beispiel #2
0
 /**
  * Pending function for with(), joining other tables to current
  */
 protected function withPending()
 {
     $joins = $this->pending['with'];
     foreach ($joins as $join) {
         $local = count($join) > 1 ? array_slice($join, -2, 1)[0] : $this->name;
         $foreign = end($join);
         $relation = Relation::table($local)->with($foreign);
         $data = $this->data;
         foreach ($join as $part) {
             $data = $relation->build($data, $part);
         }
     }
 }