页面优化,功能修复
This commit is contained in:
41
app/Http/Controllers/Site/FeedbackController.php
Normal file
41
app/Http/Controllers/Site/FeedbackController.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Controllers\Site;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\FeedbackEntry;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class FeedbackController extends Controller
|
||||
{
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'feedback_type' => ['required', 'in:tool,model,news,guide,other'],
|
||||
'title' => ['required', 'string', 'max:180'],
|
||||
'description' => ['required', 'string', 'max:4000'],
|
||||
'contact' => ['nullable', 'string', 'max:160'],
|
||||
], [
|
||||
'feedback_type.required' => '请选择反馈类型',
|
||||
'title.required' => '请填写标题',
|
||||
'description.required' => '请填写详细说明',
|
||||
]);
|
||||
|
||||
FeedbackEntry::query()->create([
|
||||
'feedback_type' => $validated['feedback_type'],
|
||||
'title' => $validated['title'],
|
||||
'description' => $validated['description'],
|
||||
'contact' => $validated['contact'] ?? null,
|
||||
'status' => 'new',
|
||||
'ip_address' => $request->ip(),
|
||||
]);
|
||||
|
||||
return redirect()
|
||||
->back()
|
||||
->with('status', '反馈提交成功,感谢你的建议');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ use App\Http\Controllers\Controller;
|
||||
use App\Models\AiModel;
|
||||
use App\Models\Article;
|
||||
use App\Models\Category;
|
||||
use App\Models\SiteSetting;
|
||||
use App\Models\Tool;
|
||||
use App\Support\MarkdownRenderer;
|
||||
use Illuminate\Contracts\View\View;
|
||||
@@ -59,15 +60,54 @@ class ToolController extends Controller
|
||||
];
|
||||
})->values();
|
||||
|
||||
$moduleConfig = SiteSetting::query()
|
||||
->where('setting_key', 'home_modules')
|
||||
->value('setting_value');
|
||||
|
||||
$modules = collect([
|
||||
'hot_tools' => ['enabled' => true, 'limit' => 18],
|
||||
'latest_tools' => ['enabled' => true, 'limit' => 18],
|
||||
'category_sections' => ['enabled' => true, 'limit' => 18],
|
||||
'channel_cards' => ['enabled' => true, 'limit' => 1],
|
||||
'promo_banners' => ['enabled' => true, 'limit' => 1],
|
||||
]);
|
||||
|
||||
if (is_array($moduleConfig)) {
|
||||
foreach ($moduleConfig as $module) {
|
||||
if (!is_array($module) || empty($module['key'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$key = (string) $module['key'];
|
||||
if ($modules->has($key)) {
|
||||
$modules[$key] = [
|
||||
'enabled' => (bool) ($module['enabled'] ?? true),
|
||||
'limit' => max(1, min(30, (int) ($module['limit'] ?? 18))),
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$hotToolsLimit = (int) ($modules['hot_tools']['limit'] ?? 18);
|
||||
$latestToolsLimit = (int) ($modules['latest_tools']['limit'] ?? 18);
|
||||
$sectionLimit = (int) ($modules['category_sections']['limit'] ?? 18);
|
||||
|
||||
$categorySections = $categorySections->map(function (array $section) use ($sectionLimit): array {
|
||||
$section['tools'] = $section['tools']->take($sectionLimit);
|
||||
|
||||
return $section;
|
||||
});
|
||||
|
||||
return [
|
||||
'categories' => $categories,
|
||||
'categorySections' => $categorySections,
|
||||
'hotTools' => $portalTools->take(18),
|
||||
'latestTools' => Tool::query()->published()->with('category')->latest('published_at')->limit(18)->get(),
|
||||
'hotTools' => $portalTools->take($hotToolsLimit),
|
||||
'latestTools' => Tool::query()->published()->with('category')->latest('published_at')->limit($latestToolsLimit)->get(),
|
||||
'filters' => $request->only(['q', 'pricing', 'api', 'tab']),
|
||||
'activeTab' => $activeTab,
|
||||
'tabOptions' => $this->tabOptions(),
|
||||
'toolStats' => $this->buildToolStats(),
|
||||
'modules' => $modules,
|
||||
];
|
||||
});
|
||||
|
||||
@@ -292,4 +332,3 @@ class ToolController extends Controller
|
||||
return array_values(array_unique(array_slice($tags, 0, 8)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user