静态资源

This commit is contained in:
2020-09-16 08:35:46 +08:00
parent 24315e4798
commit ac3b53b163
40 changed files with 8270 additions and 660 deletions

View File

@@ -11,6 +11,7 @@ use Encore\Admin\Layout\Row;
use Encore\Admin\Tree;
use Encore\Admin\Widgets\Box;
use Encore\Admin\Widgets\Form as WidgetsForm;
use Illuminate\Support\MessageBag;
class IndexController extends AdminController
{
@@ -35,6 +36,14 @@ class IndexController extends AdminController
$form->text('title', '分类名称')->rules('required');
$form->select('type', '分类类型')
->options(Category::TYPES)
->when('show', function (WidgetsForm $form) {
$form->select('article_id', '关联文章')
->options(function ($option, $info) {
return Article::whereHas('category', function ($q) {
$q->where('type', 'show');
})->pluck('title', 'id');
})->help('当分类类型是文章详情的时候需要选择关联文章');
})
->required();
$form->textarea('description', '分类简介')
->rules('nullable');
@@ -43,6 +52,7 @@ class IndexController extends AdminController
->removable()
->uniqueName();
$form->number('order', '排序')->default(0);
$form->switch('top_show', '顶部导航显示')->states()->default(0);
$form->switch('status', '显示')->states()->default(1);
$form->action(admin_url('categories'));
@@ -89,6 +99,14 @@ class IndexController extends AdminController
$form->text('title', '分类名称')->rules('required');
$form->select('type', '分类类型')
->options(Category::TYPES)
->when('show', function (Form $form) {
$form->select('article_id', '关联文章')
->options(function ($option, $info) {
return Article::whereHas('category', function ($q) {
$q->where('type', 'show');
})->pluck('title', 'id');
})->help('当分类类型是文章详情的时候需要选择关联文章');
})
->required()
->rules('required');
$form->textarea('description', '分类简介')->rows(4)->rules('nullable');
@@ -97,27 +115,19 @@ class IndexController extends AdminController
->removable()
->uniqueName();
$form->number('order', '排序')->default(0);
$form->select('article_id', '关联文章')
->options(function ($option, $info) {
$category = $this;
if ($category) {
return Article::where('category_id', $category->id)->pluck('title', 'id');
} else {
return [0 => '没有数据'];
}
})->help('当分类类型是文章详情的时候需要选择关联文章');
$form->switch('top_show', '顶部导航显示')->states()->default(0);
$form->switch('status', '显示')->states()->default(1);
$form->saving(function (Form $form) {
if (request()->has('title')) {
if (request()->type == Category::TYPE_SHOW && empty(request()->article_id)) {
$error = new MessageBag([
'title' => '错误',
'message' => '文章类型是文章详情的时候需要选择关联文章',
]);
return back()->withInput()->with(compact('error'));
// $error = new MessageBag([
// 'title' => '错误',
// 'message' => '文章类型是文章详情的时候需要选择关联文章',
// ]);
//
// return back()->withInput()->with(compact('error'));
}
}