{"size": 2574, "ext": "js", "max_stars_repo_path": "public/js/vue.js", "max_stars_repo_name": "abdullahessam/vuecrud", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "public/js/vue.js", "max_issues_repo_name": "abdullahessam/vuecrud", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "public/js/vue.js", "max_forks_repo_name": "abdullahessam/vuecrud", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 28.2857142857, "max_line_length": 91, "alphanum_fraction": 0.3581973582}
console.clear();
var app = new Vue({
    el: '#app',
    data: {
        message: 'Hello Vue!',
        users:[],
        name: '',
        email: '',
        password: '',
        errors:[],
    },
    mounted:function(){
        this.getUsers()
    },
    methods: {
        store: function () {

            axios.post('/user', {
                name: this.name,
                email: this.email,
                password: this.password,

            })
                .then(function (response) {

                   if (response.data.status==false){
                       this.errors=response.data.errors;
                       swal("error!", "fail");

                   }else {
                       this.errors='';
                       swal("success", "success");
                       this.name = '';
                       this.email = '';
                       this.password = '';

                   }
                }.bind(this))
                .catch(function (error) {
                    console.log(error);
                });


            this.getUsers();


        }
        ,
        getUsers: function () {
            axios.get('/user').then(function (response) {
                this.users=response.data.users;
                console.log(response.data);
            }.bind(this)).catch(function (error) {
                console.log(error);
            });
        }
        ,
        edit:function (user) {

            this.name=user.name;
            this.email=user.email;
        },
        deleteUser:function (user) {
            swal({
                title: "Are you sure?",
                text: "Once deleted, you will not be able to recover this imaginary file!",
                icon: "warning",
                buttons: true,
                dangerMode: true,
            })
                .then((willDelete) => {
                    if (willDelete) {
                        axios.delete('/user/'+user.id) .then(function (response) {
                            swal("Poof! Your imaginary file has been deleted!", {
                                icon: "success",
                            });
                            this.getUsers();
                            console.log(response);
                        }.bind(this))
                            .catch(function (error) {
                                console.log(error);
                            });

                    } else {
                        swal("Your imaginary file is safe!");
                    }
                });
        }
    }

});