@extends('layouts.app')
@section('page_title', $role->exists ? __('app.edit_role') : __('app.add_role'))
@section('content')
<form method="POST" action="{{ $role->exists ? route('roles.update',$role) : route('roles.store') }}">@csrf @if($role->exists) @method('PUT') @endif
<div class="top-card p-3"><div class="row g-3"><div class="col-md-6"><label class="easy-label">{{ __('app.name') }}</label><input name="name" value="{{ old('name',$role->name) }}" class="form-control form-control-lg" required></div><div class="col-md-6"><label class="easy-label">{{ __('app.role_code') }}</label><input name="code" value="{{ old('code',$role->code) }}" class="form-control form-control-lg" required></div><div class="col-12"><h5 class="fw-bold">{{ __('app.permissions') }}</h5><div class="row g-2">@foreach($permissions as $key=>$label)<div class="col-md-3 col-6"><label class="top-card p-3 w-100"><input type="checkbox" name="permissions[]" value="{{ $key }}" @checked(in_array($key, old('permissions',$role->permissions ?? [])))> {{ $label }}</label></div>@endforeach</div></div><div class="col-12"><label><input type="checkbox" name="is_active" value="1" @checked(old('is_active',$role->is_active ?? true))> {{ __('app.active') }}</label></div><div class="col-12 text-end"><button class="btn btn-success btn-lg">{{ __('app.save') }}</button></div></div></div>
</form>
@endsection
