orderBy('name')->paginate(20); return view('admin.solutions.index', compact('solutions')); } public function create(): View { return view('admin.solutions.form', ['solution' => null]); } public function store(Request $request) { $data = $request->validate([ 'name' => ['required', 'string', 'max:120'], 'slug' => ['required', 'string', 'max:120', 'unique:solutions,slug'], 'power_segment' => ['nullable', 'in:lt30,30-65,65-100,gt100'], 'application' => ['nullable', 'in:charger,powerbank,car,dock'], 'chip_platform' => ['nullable', 'in:protocol,soc,rectifier'], 'power' => ['nullable', 'string', 'max:40'], 'summary' => ['nullable', 'string', 'max:255'], 'advantages' => ['nullable', 'string'], 'description' => ['nullable', 'string'], 'cover' => ['nullable', 'string', 'max:255'], 'status' => ['required', 'in:published,draft'], 'sort' => ['integer'], ]); Solution::create($data); return redirect()->route('admin.solutions.index')->with('success', '方案已创建'); } public function edit(Solution $solution): View { return view('admin.solutions.form', compact('solution')); } public function update(Request $request, Solution $solution) { $data = $request->validate([ 'name' => ['required', 'string', 'max:120'], 'slug' => ['required', 'string', 'max:120', 'unique:solutions,slug,' . $solution->id], 'power_segment' => ['nullable', 'in:lt30,30-65,65-100,gt100'], 'application' => ['nullable', 'in:charger,powerbank,car,dock'], 'chip_platform' => ['nullable', 'in:protocol,soc,rectifier'], 'power' => ['nullable', 'string', 'max:40'], 'summary' => ['nullable', 'string', 'max:255'], 'advantages' => ['nullable', 'string'], 'description' => ['nullable', 'string'], 'cover' => ['nullable', 'string', 'max:255'], 'status' => ['required', 'in:published,draft'], 'sort' => ['integer'], ]); $solution->update($data); return redirect()->route('admin.solutions.index')->with('success', '方案已更新'); } public function destroy(Solution $solution) { $solution->delete(); return redirect()->route('admin.solutions.index')->with('success', '方案已删除'); } }