在管理界面上,我将编辑器的内容保存到数据库中,可以创建多个CSS,并可以更改其顺序。
数据库表: id(bigint)|名称(varchar)|内容(长文本)
这不起作用: Storage :: disk('local')-> append('storage / css / custom.css',$ request-> input('content'));
编辑时,如何生成在数据库中创建的内容并将其保存到CSS文件中?
更新:备份已解决,但如何将数据库中css文件中的数据仅放在每个表之前:{“ content:” ...}?
private function saveToFile()
{
$cssmerge = Css::all('content');
Storage::disk('public')->put('css/custom.css', $cssmerge);
}
谢谢!
CssController.php:
public function store(Request $request)
{
$csscontent = $request->all();
// Create css style
$csscontent = new Css;
$csscontent->name = $request->input('name');
$csscontent->content = $request->input('content');
$csscontent->save();
return redirect('backend/css')->withSuccessMessage( __('Successfully created!'));
}
public function update(Request $request, $id)
{
// Update css
Storage::disk('local')->append('storage/css/custom.css', $request->input('content'));
$csscontent = Css::findOrFail($id);
$csscontent->name = $request->input('name');
$csscontent->content = $request->input('content');
$csscontent->save();
switch($request->input('save-form')) {
case 'save-btn-redirect':
return redirect('backend/css')->withSuccessMessage( __('Successfully modified!'));
break;
case 'save-btn':
return back()->withSuccessMessage( __('Successfully modified!'));
break;
}
return view('backend.css.index', compact('csscontent'));
}