|
@@ -1003,6 +1003,9 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
*/
|
|
|
public function upWebsiteCategory(array $data): array
|
|
|
{
|
|
|
+
|
|
|
+ var_dump("更新数据:", $data);
|
|
|
+ $pinyin = new Pinyin();
|
|
|
Db::beginTransaction();
|
|
|
try {
|
|
|
if ($data['category_arr_id']) {
|
|
@@ -1032,10 +1035,13 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
'category_id' => end($value),
|
|
|
];
|
|
|
|
|
|
+ $aLIas_pinyin = $pinyin->permalink($info['name'], '');
|
|
|
+ var_dump($aLIas_pinyin, '别名');
|
|
|
$values = [
|
|
|
'website_id' => $data['website_id'],
|
|
|
'name' => $info['name'] ?? '',
|
|
|
'alias' => $info['name'] ?? '',
|
|
|
+ 'aLIas_pinyin' => $aLIas_pinyin ?? '',
|
|
|
'sort' => $info['sort'] ?? 0,
|
|
|
'pid' => $info['pid'] ?? 0,
|
|
|
'pid_arr' => $info['pid_arr'] ?? json_encode([]),
|
|
@@ -1068,6 +1074,7 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
unset($values['alias']);
|
|
|
}
|
|
|
|
|
|
+ var_dump("更新数据:", $values);
|
|
|
WebsiteCategory::updateOrCreate($attributes, $values);
|
|
|
}
|
|
|
}
|
|
@@ -1168,10 +1175,9 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
$pinyin = new Pinyin();
|
|
|
$letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
|
|
for ($i = 0; $i < count($result); $i++) {
|
|
|
- $randss = substr(str_shuffle($letters), 0, 4);
|
|
|
- $result[$i]['alias_pinyin'] = $pinyin->permalink($result[$i]['alias'], '') . $randss;
|
|
|
- var_dump($result[$i]['alias_pinyin'], $i . '----------');
|
|
|
- WebsiteCategory::where(['id' => $result[$i]['id']])->update(['alias_pinyin' => $result[$i]['alias_pinyin']]);
|
|
|
+
|
|
|
+ $result[$i]['aLIas_pinyin'] = $pinyin->permalink($result[$i]['alias'], '');
|
|
|
+ WebsiteCategory::where(['id' => $result[$i]['id']])->update(['aLIas_pinyin' => $result[$i]['aLIas_pinyin']]);
|
|
|
}
|
|
|
var_dump($result, '--------222----');
|
|
|
if ($result) {
|
|
@@ -1187,16 +1193,16 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
];
|
|
|
$alias = $data['alias'];
|
|
|
$pinyin = new Pinyin();
|
|
|
- $alias_pinyin = $pinyin->permalink($alias, '');
|
|
|
-
|
|
|
+ $aLIas_pinyin = $pinyin->permalink($alias, '');
|
|
|
+
|
|
|
$result = WebsiteCategory::where($where)->first();
|
|
|
$result = $result->toArray();
|
|
|
|
|
|
$letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
|
|
|
|
|
- $randss = substr(str_shuffle($letters), 0, 4);
|
|
|
- if (!isset($data['alias_pinyin']) || $data['alias_pinyin'] == '') {
|
|
|
- $data['alias_pinyin'] = $alias_pinyin . $randss;
|
|
|
+
|
|
|
+ if (!isset($data['aLIas_pinyin']) || $data['aLIas_pinyin'] == '') {
|
|
|
+ $data['aLIas_pinyin'] = $aLIas_pinyin;
|
|
|
}
|
|
|
$result = WebsiteCategory::where($where)->update($data);
|
|
|
if ($result) {
|
|
@@ -2127,15 +2133,15 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
$category['child'] = $child->map(function ($item) use ($parentCategories) {
|
|
|
$alias = $item->alias;
|
|
|
$category_id = $item->category_id;
|
|
|
- $alias_pinyin = $item->aLIas_pinyin;
|
|
|
+ $aLIas_pinyin = $item->aLIas_pinyin;
|
|
|
$parent = $parentCategories->get($item->pid);
|
|
|
$parentAlias = $parent ? $parent->aLIas_pinyin : '';
|
|
|
$result = [
|
|
|
'name' => $alias,
|
|
|
'cid' => $category_id
|
|
|
];
|
|
|
- if (!empty($alias_pinyin) && !empty($parentAlias)) {
|
|
|
- $result['path'] = "/{$parentAlias}/{$alias_pinyin}/";
|
|
|
+ if (!empty($aLIas_pinyin) && !empty($parentAlias)) {
|
|
|
+ $result['path'] = "/{$parentAlias}/{$aLIas_pinyin}/";
|
|
|
}
|
|
|
return $result;
|
|
|
})->values()->all();
|
|
@@ -2190,16 +2196,16 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
return Result::error("暂无该网站", 0);
|
|
|
}
|
|
|
|
|
|
- if (isset($data['pinyin']) &&!empty($data['pinyin'])) {
|
|
|
- $result = WebsiteCategory::where('website_id',$data['website_id'])->where('aLIas_pinyin',$data['pinyin'])->first(['category_id']);
|
|
|
+ if (isset($data['pinyin']) && !empty($data['pinyin'])) {
|
|
|
+ $result = WebsiteCategory::where('website_id', $data['website_id'])->where('aLIas_pinyin', $data['pinyin'])->first(['category_id']);
|
|
|
}
|
|
|
- if(isset($data['foot_pinyin']) &&!empty($data['foot_pinyin'])){
|
|
|
- $result = FooterCategory::where('website_id',$data['website_id'])->where('name_pinyin',$data['foot_pinyin'])->first(['id']);
|
|
|
+ if (isset($data['foot_pinyin']) && !empty($data['foot_pinyin'])) {
|
|
|
+ $result = FooterCategory::where('website_id', $data['website_id'])->where('name_pinyin', $data['foot_pinyin'])->first(['id']);
|
|
|
}
|
|
|
if (!isset($result) || empty($result)) {
|
|
|
- return Result::error("暂无该导航",0);
|
|
|
+ return Result::error("暂无该导航", 0);
|
|
|
}
|
|
|
- return Result::success($result);
|
|
|
+ return Result::success($result);
|
|
|
}
|
|
|
|
|
|
|