@extends('layouts.master')
@section('title', 'Edit Permission')
@section('content')
<div class="container">
    <div class="card-header bg-primary text-white py-3">
            <h5 class="mb-0"><i class="fas fa-chart-line me-2"></i> Edit Permission</h5>
        </div>

    @if ($errors->any())
        <div class="alert alert-danger">
            <ul>
                @foreach ($errors->all() as $error)
                    <li>{{ $error }}</li>
                @endforeach
            </ul>
        </div>
    @endif

    <form action="{{ route('permissions.update', $permission->id) }}" method="POST">
        @csrf
        @method('PUT')

        <div class="form-group mb-3">
            <label for="name">Permission Name</label>
            <input type="text" name="name" class="form-control" value="{{ $permission->name }}" required>
        </div>
            <div class="mb-3">
        <label>Actions</label><br>
        <input type="checkbox" name="actions[]" value="view"> View
        <input type="checkbox" name="actions[]" value="create"> Create
        <input type="checkbox" name="actions[]" value="edit"> Edit
        <input type="checkbox" name="actions[]" value="update"> Update
        <input type="checkbox" name="actions[]" value="delete"> Delete
        </div>
        <button type="submit" class="btn btn-primary">Update Permission</button>
        <a href="{{ route('permissions.index') }}" class="btn btn-secondary">Back</a>
    </form>
</div>
@endsection
