ziben69
339
3
Vue

Vue.js | Get data from CKeditor and saving it to the database

Posted 4 months ago by ziben69

Hello guys, Im looking for help with getting data from CKEditor.

I had 2 versions, and only 1 works (clear Laravel):

Controller (function store):

 public function store(Request $request)
    {
        $business = Business::create($request->all());
        if($request->has('photos')) {
            foreach ($request->photos as $photo) {
                $filename = $photo->store('public/photos');
                Photo::create([
                    'business_id' => $business->id,
                    'filename' => $filename
                ]);
            }
        }
        return redirect()->action('[email protected]');
    }

This method works for (clear Laravel):

<textarea class="form-control" rows="5" name="description" id="description"></textarea>

But I would like it to work from the vue.js level In component I have something like that (with Vue.JS component):

<template>
     <vue-ckeditor type="classic" v-model="editorData" :editors="editors"></vue-ckeditor>
</template>

<script>
    import VueCkeditor from 'vue-ckeditor5'

    export default {
        components: {
            'vue-ckeditor': VueCkeditor.component
        },
        data(){
            return {
                editors: {
                    classic: ClassicEditor
                },
                editorData: '<p>Content of the editor.</p>',
            }
        },
    }
</script>

and calling the component in the view:

<vue-ck name="description" id="description"></vue-ck>

it isn't work. Can you help me with transferring values ​​from the editor to the database? So much thanks.

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