@extends('admin.layouts.main')
@section('container')
    <div class="row">
        <!-- left column -->
        <div class="col-md-12">
            <!-- jquery validation -->
            @if (session()->has('error'))
                <div class="alert alert-danger text-center">
                    {{ session()->get('error') }}
                </div>
            @endif
            @if (session()->has('success'))
                <div class="alert alert-success text-center">
                    {{ session()->get('success') }}
                </div>
            @endif
            <div class="card card-primary">
                <div class="card-header">
                    <h3 class="card-title">เพิ่มข้อมูลโปรไฟล์</h3>
                </div>
                <!-- /.card-header -->
                <!-- form start -->
                <form action="{{ route('profiles.store') }}" method="post" enctype="multipart/form-data">
                    @csrf
                    <div class="card-body">
                        <div class="form-group">
                            <label for="exampleInputEmail1">เนื้อหา <small class="text-danger">*</small></label>
                            <textarea class="form-control" name="profiles_name" id="profiles_name" cols="30"
                                rows="10">{{ old('profiles_name') }}</textarea>
                            <small class="text-danger">{{ $errors->first('profiles_name') }}</small>
                        </div>
                        <div class="form-group">
                            <label for="exampleInputEmail1">ออฟชันก์ <small class="text-danger">*</small></label>
                            <select name="profiles_status" class="form-control" id="profiles_status">
                                <option value="0">ยังไม่เปิดใช้</option>
                                <option value="1">เปิดใช้ในทันที</option>
                            </select>
                        </div>
                    </div>
                    <!-- /.card-body -->
                    <div class="card-footer">
                        <button type="submit" class="btn btn-success">เพิ่มข้อมูล</button>
                    </div>
                </form>
            </div>
            <!-- /.card -->
        </div>
        <!--/.col (left) -->

    </div>
@endsection
@section('scriptadd')
    <script>
        $('document').ready(function() {
            $("#files").change(function() {
                if (this.files && this.files[0]) {
                    var reader = new FileReader();
                    reader.onload = function(e) {
                        $("#imgshow").html('<img src="' + e.target.result + '" align="left">')
                    }
                    reader.readAsDataURL(this.files[0]);
                }
            });
        });
    </script>
@endsection
