4 months ago

Storing Issue

Posted 4 months ago by MoeSaid

Hi mates, am facing a weird issue will store some data to the Db using axios

the issue is , when i push the data to the controller works without any issues once am trying to save it always return with err

Request failed with status code 500

here's my form

 <form >
        <textarea v-on:click="clear" v-on:keydown.enter="submit" class="form-control" v-model="msg" rows="8"></textarea>

        <button v-on:click="submit" class="btn btn-dark" type="button" name="button">
          <i class="fa fa-paper-plane"></i>


the vue component

var chat = new Vue({

          el: '#chat',

          data: {
              msg: 'Type New Message...',
              room: '{{$room->id}}',
              user: '{{auth()->user()->id}}',
              avatar: '{{auth()->user()->image}}',

          methods: {

              clear: function (e) {
                    this.msg = '';

              submit : function (e) {

        'api/chat/add' , {
                      user:     this.user,
                      avatar:   this.avatar,
                      body:     this.msg

                  }).then(function (res) {

                      // this.$emit('new' ,;

                  }).catch(function (err) {

                  this.msg = '';


my controller

public function new(Request $req)
        $msg = new GroupChat;
        $msg->room_id = $req->room;
        $msg->user_id = $req->user;
        $msg->avatar  = $req->avatar;
        $msg->body    = $req->body;


        return response()->json($req);

what am missing guys? appreciate any help.

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