将一部分HTML表单存储在数据库中

时间:2019-01-25 15:36:26

标签: php html laravel eloquent

我已使用以下代码为数据库播种。

$q = new Question;
$q->question_name = "trip_and_close";
$question = clean('
            <div class="form-group">
                <!-- all my HTML code goes here -->
            </div>
            ');
$q->question = $question;
$q->save();

$q->plant_type()
    ->attach($plant, ['order' => '2', 'section_id' => '1']);

questionsplant_type具有多对多关系,而belongsToinspections表具有<form action="/inspections/{{$inspection->id}}" method="POST"> @csrf @method('put') @foreach($inspection->plant_type->questions as $question) {!! $question->question !!} @endforeach </form> 关系。

我希望能够从数据库中检索此信息并将其插入到视图中,如下所示:

{{ }}

我无法使它正常工作。我已经尝试过htmlspecialcharsApollo Server,可以读取HTML净化器。不高兴。

当我检查保存在数据库中的数据时,表单中的类信息全部丢失。我可以将html正确保存到数据库吗?我正在使用文本数据类型。

请帮助 问候 保罗。

0 个答案:

没有答案