@extends ('layouts/template')
@section('content')
<div id="statTreeComponent" v-cloak>
        <div class="p-3 mcp-theme-1">
            <div class="card">
                <div class="card-header">
                    <h6 class="font-weight-bold mb-0">Create Stat Tree</h6>
                </div>
                <div class="card-body">
                    <form class="row" @submit.prevent="submit" method="POST">
                        <div class="col-md-4">
                            <div class="form-group">
                                <label>Name</label>
                                <input type="text" class="form-control" name="name" v-model="form.name" required />
                            </div>
                        </div>
                        <div class="col-md-4">
                            <div class="form-group">
                                <label>Model</label>
                                <input type="text" class="form-control" name="table" v-model="form.model" required />
                            </div>
                        </div>
                        <div class="col-md-4">
                            <div class="form-group">
                                <label>Slug</label>
                                <input type="text" class="form-control" name="slug" v-model="form.slug" required />
                            </div>
                        </div>
                        <div class="col-12">
                            <button type="submit" class="btn btn-sm btn-primary">Submit</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
</div>

<script type="text/javascript">
    var app = new Vue({
        el: '#statTreeComponent',
        data: {
            form: {},
        },
        methods: {
            submit: function() {

                $.post("{{ route('practice-management.api.statTree.create') }}", this.form, function(response) {
                    if (response.success) {
                        fastLoad('/practice-management/stat-trees/view/' + response.data);
                    } else {
                        alert(response.message);
                    }
                }, 'json');
            }
        },
    })
</script>


@endsection