how to get json values from db in edit page in laravel

∥☆過路亽.° 提交于 2021-02-11 14:19:39

问题


Hi guys i have form with multiple sections so on time of insert i am storing the particular sections which ever i have choose. so those values i am storing it in json format in db.Now i want to get it in my edit page only those particular sections values..

Here is my function from where i am storing all json code:

function toggler(section_value, from_where)
{
    var html_question_section         = '';
    var html_question_section_display = '';
    var section_counter               = 0;

    if(from_where == 'question')
    {
        question_section_counter += 1;
    }
    else if(from_where == 'solution')
    {
        soution_section_counter += 1;
    }

    if(section_value == 'text_section')
    {
        question_text_section_counter += 1;
        section_counter = question_text_section_counter;
    }
    else if(section_value == 'image_section')
    {
        question_image_section_counter += 1;
        section_counter = question_image_section_counter;
    }
    else if(section_value == 'sol_text_section')
    {
        soution_text_section_counter += 1;
        section_counter = soution_text_section_counter;
    }
    else if(section_value == 'sol_text_chk_section')
    {
        soution_text_chk_section_counter += 1;
        section_counter = soution_text_chk_section_counter;
    }
    else if(section_value == 'sol_image_chk_section')
    {
        soution_img_chk_section_counter += 1;
        section_counter = soution_img_chk_section_counter;
    }
    else if(section_value == 'sol_text_radio_section')
    {
        soution_text_radio_section_counter += 1;
        section_counter = soution_text_radio_section_counter;
    }
    else if(section_value == 'sol_image_radio_section')
    {
        soution_img_radio_section_counter += 1;
        section_counter = soution_img_radio_section_counter;
    }

    html_question_section         =  getSectionHtml(section_value, section_counter, from_where);
    html_question_section_display =  getSectionDisplay(section_value, section_counter);
    template_json                 =  getTemplateJSON(section_value, from_where);

    if(from_where == 'question')
    {
        $('#div_question_section').append(html_question_section);
        $('#div_display_question_section').append(html_question_section_display);
    }
    else
    {
        $('#div_solution_section').append(html_question_section);
        $('#div_display_solution_section').append(html_question_section_display);
    }

    var json_string = JSON.stringify(template_json, undefined, 2);
    $('.json_template').html(json_string).val(json_string);
}

Here is my code from controller:

    $template->template_json = json_encode($request->input('json_template'));

Can anyone help me how can i get those values in edit page.depending on index i should get.

来源:https://stackoverflow.com/questions/64679847/how-to-get-json-values-from-db-in-edit-page-in-laravel

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!