本文整理匯總了PHP中Translations::find方法的典型用法代碼示例。如果您正苦於以下問題:PHP Translations::find方法的具體用法?PHP Translations::find怎麽用?PHP Translations::find使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Translations
的用法示例。
在下文中一共展示了Translations::find方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: find
public static function find($id, $columns = array('*'))
{
if (is_array($id) && empty($id)) {
return new Collection();
}
$instance = new static();
$obj = $instance->newQuery()->find($id, $columns);
if (is_array($id)) {
$prop = new ReflectionProperty(get_class($obj), 'items');
}
$col = array();
if (isset($prop->name)) {
$prop->setAccessible(1);
foreach ($prop->getValue($obj) as $k => $object) {
$translation = Translations::find($object->table . "_" . $object->id . "_" . strtolower(Config::get('cms.currlang.code')));
$object->setRawAttributes(json_decode($translation->translation, 1));
$col[] = $object;
}
$prop->setValue($obj, $col);
} else {
$translation = Translations::find($obj->table . "_" . $obj->id . "_" . strtolower(Config::get('cms.currlang.code')));
$obj->setRawAttributes(json_decode($translation->translation, 1));
$seo = $obj->seo()->first();
if (!is_null($seo)) {
Config::set('cms.seo', $seo);
}
}
//
return $obj;
}
示例2: mergeTranslations
/**
* Merge the translations of two translations.
*
* @param Translations $from
* @param Translations $to
* @param int $options
*/
public static function mergeTranslations(Translations $from, Translations $to, $options = self::DEFAULTS)
{
if ($options & self::REMOVE) {
$filtered = [];
foreach ($to as $entry) {
if ($from->find($entry)) {
$filtered[$entry->getId()] = $entry;
}
}
$to->exchangeArray($filtered);
}
foreach ($from as $entry) {
if ($existing = $to->find($entry)) {
$existing->mergeWith($entry);
} elseif ($options & self::ADD) {
$to[] = $entry;
}
}
}