1 month ago

store multiple data in multiple column on post laravel

Posted 1 month ago by raza9355

this is my controller what i have tried

 public function getTranslation(Request $request){

    $dataa = new trans();
    $lang = new language();
    $data = $request->all();
    foreach ($request->get('translation')  as $key=>$translation):
        $detail = $dataa;
        $detail->translation = $translation;

this is ajax

jQuery(document).ready(function () {
                  $('#saveBtn').on('click', function (e) {
                    var access = [];
          $('input[name^="translation"]').each(function() {
                      var value = $("#ajax-crud-modal").find('input[name="post_id"]').val();
                          headers: {
                              'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                          url: '{{ url("/surname/translation") }}',
                          type: 'POST',
                          data: {
                            ethnicity: $('[name=ethnicity]').val(),
                            translation: access,
                          success: function (result, exception) {

                          error: function (jqXHR, exception) {
                              alert(jqXHR.status + ' - ' + exception);

this is the ajax i am sending to the controller from translation i am getting array i want to add that store data of array on new column like when i post data all fields value will save in new column in db i dont know how to achieve that from controller i am new to laravel help will be appreciated

Please sign in or create an account to participate in this conversation.