@extends('admin.layout.index')
@push('css-head')
@endpush
@section('content')
<!-- Page header -->
<div class="page-header page-header-light">
    <div class="breadcrumb-line breadcrumb-line-light header-elements-md-inline">
        <div class="d-flex">
            <div class="breadcrumb">
                <a href="{{url('/admin')}}" class="breadcrumb-item"><i class="icon-home2 mr-2"></i> Dashboard</a>
                <a href="{{url('/admin/permissions')}}" class="breadcrumb-item"> Permissions</a>
                <span class="breadcrumb-item active">Update: {{$permission->name}}</span>
            </div>
        </div>
    </div>
</div>
<!-- /page header -->

<!-- Content area -->
<div class="content">
    <div class="card">
        <div class="card-body">
            @if (count($errors) > 0)
                <div class="alert alert-danger alert-no-border alert-txt-colored alert-close alert-dismissible fade show" role="alert">
                    <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                        <span aria-hidden="true">×</span>
                    </button>
                    <strong>Whoops!</strong> There were some problems with your input.
                    <ul>
                      @foreach ($errors->all() as $error)
                        <li>{{ $error }}</li>
                      @endforeach
                    </ul>
                </div>
            @endif
            {!!Form::model($permission,['method'=>'PETCH','url'=>['admin/permissions/update',$permission->id]])!!}
                <div class="form-group">
                    <label>Name:</label>
                    <input type="text" class="form-control" name="name" value="{{$permission->display_name}}" id="name" placeholder="Name" required="">
                </div>
                <div class="form-group">
                    <label>Parent:</label>
                    <select class="form-control" name="parent">
                        <option disabled="" selected="" value="">Choose One..</option>
                        @foreach($parents as $row)
                            <option value="{{$row->id}}" @if($row->id == $permission->parent) {{'selected'}} @endif>{{$row->display_name}}</option>
                        @endforeach
                    </select>
                </div>
                <div class="text-right">
                    <a href="{{ url('admin/permissions/edit') }}/{{ $permission->id }}" class="btn btn-secondary pull-left">
                        Refresh
                         <i class="icon-reload-alt ml-2"></i>
                    </a>
                    <button type="submit" class="btn btn-primary">Update <i class="icon-pencil7 ml-2"></i></button>
                </div>
            {!! Form::close() !!}
        </div>
    </div>
</div>
<!-- /content area -->
@endsection

@push('scripts')
@endpush
