|
@@ -8,6 +8,7 @@ use Illuminate\Http\Request;
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
use Modules\Common\Errors\Errors;
|
|
|
use Modules\Common\Exceptions\CommonBusinessException;
|
|
|
+use Modules\Common\Services\CommonConfigService;
|
|
|
use Modules\User\Http\Controllers\UserTrait;
|
|
|
|
|
|
class FirstPageController extends CatchController
|
|
@@ -19,13 +20,15 @@ class FirstPageController extends CatchController
|
|
|
* 首页列表
|
|
|
*/
|
|
|
public function list(Request $request) {
|
|
|
- $firstPageListTypeMap = collect(config('common.common.firstPageListType'))->keyBy('val')->toArray();
|
|
|
+ $firstPageListTypeMap = CommonConfigService::getFirstPageListTypeMap();
|
|
|
+ $miniprogramTypeMap = CommonConfigService::getMiniprogramTypeMap();
|
|
|
$result = DB::table('first_pages')
|
|
|
->orderBy('id', 'desc')
|
|
|
->paginate($request->input('limit', 15));
|
|
|
foreach ($result as $item) {
|
|
|
$item->type_str = $firstPageListTypeMap[$item->type]['label'] ?? '';
|
|
|
$item->duanjus = collect(\json_decode($item->duanjus, true))->sortBy('sort');
|
|
|
+ $item->miniprogram_type_str = $miniprogramTypeMap[$item->miniprogram_type]['label'] ?? '';
|
|
|
}
|
|
|
return $result;
|
|
|
}
|
|
@@ -39,13 +42,17 @@ class FirstPageController extends CatchController
|
|
|
public function add(Request $request) {
|
|
|
$this->validate($request, [
|
|
|
'type' => 'required|in:1,2',
|
|
|
- 'status' => 'required|in:0,1'
|
|
|
+ 'status' => 'required|in:0,1',
|
|
|
+ 'miniprogram_type' => 'required|in:1,2'
|
|
|
]);
|
|
|
|
|
|
$now = date('Y-m-d H:i:s');
|
|
|
if(1 == $request->input('status')) {
|
|
|
DB::table('first_pages')
|
|
|
- ->where('type', $request->input('type'))
|
|
|
+ ->where([
|
|
|
+ 'type' => $request->input('type'),
|
|
|
+ 'miniprogram_type' => $request->input('miniprogram_type')
|
|
|
+ ])
|
|
|
->update(['status' => 0, 'updated_at' => $now]);
|
|
|
}
|
|
|
|
|
@@ -53,6 +60,7 @@ class FirstPageController extends CatchController
|
|
|
->insert([
|
|
|
'type' => $request->input('type'),
|
|
|
'status' => $request->input('status'),
|
|
|
+ 'miniprogram_type' => $request->input('miniprogram_type'),
|
|
|
'created_at' => $now,
|
|
|
'updated_at' => $now,
|
|
|
]);
|
|
@@ -76,7 +84,10 @@ class FirstPageController extends CatchController
|
|
|
|
|
|
$now = date('Y-m-d H:i:s');
|
|
|
DB::table('first_pages')
|
|
|
- ->where('type', $info->type)
|
|
|
+ ->where([
|
|
|
+ 'type' => $info->type,
|
|
|
+ 'miniprogram_type' => $info->miniprogram_type,
|
|
|
+ ])
|
|
|
->update(['status' => 0, 'updated_at' => $now]);
|
|
|
DB::table('first_pages')
|
|
|
->where('id', $request->input('id'))
|