|
...
|
...
|
@@ -5,6 +5,8 @@ namespace App\Models; |
|
|
|
use App\Helper\Translate;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
use Illuminate\Support\Str;
|
|
|
|
use function MongoDB\select_server;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 路由映射表
|
|
...
|
...
|
@@ -23,12 +25,15 @@ class RouteMap extends Model |
|
|
|
const SOURCE_PRODUCT_CATE = 'product_category';
|
|
|
|
const SOURCE_PRODUCT_KEYWORD = 'product_keyword';
|
|
|
|
const SOURCE_PAGE = 'page'; //单页面
|
|
|
|
|
|
|
|
//路由类型
|
|
|
|
const SOURCE_BLOG = 'blog';
|
|
|
|
const SOURCE_BLOG_CATE = 'blog_category';
|
|
|
|
const SOURCE_NEWS = 'news';
|
|
|
|
// 自定义界面
|
|
|
|
const SOURCE_CUSTOM = 'custom';
|
|
|
|
const SOURCE_NEWS_CATE = 'news_category';
|
|
|
|
|
|
|
|
//路由二级目录
|
|
|
|
const PATH_NEWS_CATE = 'news_catalog';
|
|
|
|
const PATH_BLOG_CATE = 'blog_catalog';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生成路由标识
|
|
|
|
* @param $title
|
|
...
|
...
|
@@ -70,9 +75,20 @@ class RouteMap extends Model |
|
|
|
if(in_array($route, $fixed)){
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
$route = self::where('project_id', $project_id)->where('route', $route)->first();
|
|
|
|
$where = [
|
|
|
|
'project_id' => $project_id,
|
|
|
|
'route' => $route,
|
|
|
|
'source' => $source
|
|
|
|
];
|
|
|
|
if($source == self::SOURCE_BLOG_CATE){
|
|
|
|
$where['path'] = self::PATH_BLOG_CATE;
|
|
|
|
}
|
|
|
|
if($source == self::SOURCE_NEWS_CATE){
|
|
|
|
$where['path'] = self::PATH_NEWS_CATE;
|
|
|
|
}
|
|
|
|
$route = self::where($where)->first();
|
|
|
|
if($route){
|
|
|
|
if($route->source == $source && $route->source_id == $source_id){
|
|
|
|
if($route->source_id == $source_id){
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
...
|
...
|
@@ -102,6 +118,12 @@ class RouteMap extends Model |
|
|
|
$route_map->source = $source;
|
|
|
|
$route_map->source_id = $source_id;
|
|
|
|
$route_map->project_id = $project_id;
|
|
|
|
if($source == self::SOURCE_BLOG_CATE){
|
|
|
|
$route_map->path = self::PATH_BLOG_CATE;
|
|
|
|
}
|
|
|
|
if($source == self::SOURCE_NEWS_CATE){
|
|
|
|
$route_map->path = self::PATH_NEWS_CATE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$route_map->route = $route;
|
|
|
|
$route_map->save();
|
...
|
...
|
|