|
@@ -3,6 +3,7 @@
|
|
|
namespace App\Distributor\Controllers;
|
|
|
|
|
|
use App\Distributor\Repositories\DistAdminUsersSetting;
|
|
|
+use App\Distributor\Repositories\DistAppearanceTemplate;
|
|
|
use App\Distributor\Repositories\SitePages;
|
|
|
use App\Models\SitePages as Model;
|
|
|
use App\Distributor\Repositories\SitePagesTag;
|
|
@@ -21,7 +22,12 @@ class SitePagesController extends AdminDistController
|
|
|
{
|
|
|
public function title()
|
|
|
{
|
|
|
- return admin_trans( 'admin.pages');
|
|
|
+ $pageType = getTempValue('location');
|
|
|
+ if ($pageType == 0) {
|
|
|
+ return admin_trans( 'admin.pages');
|
|
|
+ } else {
|
|
|
+ return admin_trans( 'admin.landing_page');
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -29,8 +35,17 @@ class SitePagesController extends AdminDistController
|
|
|
*/
|
|
|
public function index(Content $content)
|
|
|
{
|
|
|
+ if (isset($_GET['type'])) {
|
|
|
+ $pageType = $_GET['type'] == 1 ? 1 : 0;
|
|
|
+ //保存临时变量
|
|
|
+ setTempValue('location', $pageType);
|
|
|
+ } else {
|
|
|
+ $pageType = getTempValue('location');
|
|
|
+ return redirect('/dist/site-pages?type='.$pageType);
|
|
|
+ }
|
|
|
+
|
|
|
return $content
|
|
|
- ->header(admin_trans( 'admin.pages'))
|
|
|
+ ->header($this->title())
|
|
|
->description('')
|
|
|
->breadcrumb(['text'=>'','url'=>''])
|
|
|
->body($this->grid());
|
|
@@ -43,7 +58,10 @@ class SitePagesController extends AdminDistController
|
|
|
*/
|
|
|
protected function grid()
|
|
|
{
|
|
|
+ //页面类型
|
|
|
return Grid::make(SitePages::with(['pagesTag']), function (Grid $grid) {
|
|
|
+ //页面类型
|
|
|
+ $pageType = getTempValue('location');
|
|
|
//默认分页条数
|
|
|
$grid->paginate(config('admin.per_page'));
|
|
|
$grid->column('id')->sortable();
|
|
@@ -70,8 +88,11 @@ class SitePagesController extends AdminDistController
|
|
|
$filter->like('title')->width(2);
|
|
|
$filter->equal('pagesTag.id',admin_trans_label('tags'))->select('api/tag')->width(2);
|
|
|
});
|
|
|
+ //增加JS,使新增与编辑带location
|
|
|
+ $paramsUrl = 'type='.$pageType;
|
|
|
+ CommonHelper::replaceAddEditerUrl('.tree-quick-create', '.tree-quick-edit', $paramsUrl);
|
|
|
//权限与条件
|
|
|
- $grid->model()->where('dist_id', getDistributorId())->orderBy('id', 'desc');
|
|
|
+ $grid->model()->where('dist_id', getDistributorId())->where('page_type', $pageType)->orderBy('id', 'desc');
|
|
|
});
|
|
|
}
|
|
|
|
|
@@ -85,6 +106,8 @@ class SitePagesController extends AdminDistController
|
|
|
protected function detail($id)
|
|
|
{
|
|
|
return Show::make($id, Model::with(['pagesTag']), function (Show $show) {
|
|
|
+ //页面类型
|
|
|
+ $pageType = getTempValue('location');
|
|
|
$pagesTag = $show->model()->pagesTag->toArray();
|
|
|
$show->field('id');
|
|
|
$show->field('title');
|
|
@@ -123,7 +146,13 @@ class SitePagesController extends AdminDistController
|
|
|
protected function form()
|
|
|
{
|
|
|
return Form::make(SitePages::with(['pagesTag']), function (Form $form) {
|
|
|
+ //页面类型
|
|
|
+ $pageType = getTempValue('location');
|
|
|
$form->text('title')->required();
|
|
|
+ if ($pageType == 1) {
|
|
|
+ $options = DistAppearanceTemplate::getLandingPageTemplateOptions();
|
|
|
+ $form->select('template_file')->options($options)->default(current($options))->required();
|
|
|
+ }
|
|
|
$form->text('author');
|
|
|
$form->date('post_date')->format('YYYY-MM-DD')->default(date('Y-m-d'))->required();
|
|
|
$form->tags('pagesTag', '文章标签')
|
|
@@ -152,6 +181,7 @@ class SitePagesController extends AdminDistController
|
|
|
->value(DistAdminUsersSetting::getValue('visibility'));
|
|
|
//隐藏字段
|
|
|
$form->hidden('dist_id',);
|
|
|
+ $form->hidden('page_type');
|
|
|
$form->ignore(['visibility']);
|
|
|
//新建时插入JS
|
|
|
$form->creating(function (Form $form) {
|
|
@@ -163,9 +193,11 @@ class SitePagesController extends AdminDistController
|
|
|
DistAdminUsersSetting::setValue('visibility', $form->input('visibility'));
|
|
|
});
|
|
|
//保存前
|
|
|
- $form->saving(function (Form $form) {
|
|
|
+ $form->saving(function (Form $form) use ($pageType) {
|
|
|
//强制写死dist_id
|
|
|
$form->dist_id = getDistributorId();
|
|
|
+ //强制写死page_type
|
|
|
+ $form->page_type = $pageType;
|
|
|
//slug配置是否重复
|
|
|
$id = $form->getKey();
|
|
|
if ($form->slug != '') {
|