/** * Has And Belongs To Many association * * @param string $className * @param string $tableName * @param string $foreignKey * @param string $foreignKeyRelated * @return HasAndBelongsToMany */ protected function hasAndBelongsToMany($className, $tableName = null, $foreignKey = null, $foreignKeyRelated = null) { if (is_null($tableName)) { $table1 = \Inflector\Inflector::tableize(get_class($this)); $table2 = \Inflector\Inflector::tableize($className); $tables = [$table1, $table2]; asort($tables); $tableName = implode('_', $tables); } return new HasAndBelongsToMany($this, $className, $tableName, $foreignKey, $foreignKeyRelated); }
/** * Get table name * * @return string */ public static function getTable() { return is_null(static::$table_name) ? Inflector::tableize(static::className()) : static::$table_name; }