@extends('layouts.master')
@section('content')
    <div class="az-content-breadcrumb">
        <span>Brands & Products</span>
        <span>Edit Brand</span>
    </div>
    <h2 class="az-content-title" style="display: inline">
        Edit Brand
        {{-- <span>
            <a href="{{ route('brands.list') }}" class="btn btn-az-primary" style="float: right">
                Brands List
            </a>
        </span> --}}
        <span>
            <a onclick="history.back()" class="btn border" style="float: right">
                <i class="fa-solid fa-bars-staggered"></i> Back to Brands
            </a>
        </span>
    </h2>
    <div class="separator-breadcrumb border-top"></div>
    <div class="row">
        <div class="col-md-12 col-lg-12 col-xl-12">
            <div class="card card-body pd-40">
                <h5 class="card-title mg-b-20">Edit Brand Details</h5>
                @if (Session('alert'))
                    <div class="alert alert-card alert-<?php echo Session('alert-class'); ?>" role="alert">
                        <?php echo Session('alert'); ?>
                        <button class="close" type="button" data-dismiss="alert" aria-label="Close"><span
                                aria-hidden="true">&times;</span></button>
                    </div>
                @endif
                <form action="{{ route('brand.update', ['id' => Crypt::encrypt($brand->id_brands)]) }}" method="post" enctype="multipart/form-data">
                    @csrf
                    @method('PUT')
                    @if (count($errors) > 0)
                        <div class="p-1">
                            @foreach ($errors->all() as $error)
                                <div class="alert alert-warning alert-danger fade show" role="alert">{{ $error }}
                                    <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                                        <span aria-hidden="true">&times;</span>
                                    </button>
                                </div>
                            @endforeach
                        </div>
                    @endif

                    <div class="row">
                        <div class="col-md-4">
                            <div class="row-sm mg-b-20">
                                <div class="form-group">
                                    <label class="az-content-label tx-11 tx-medium tx-gray-600">Brand Name</label>
                                    <input name="brand_name" id="brand_name" class="form-control"
                                        value="{{ old('brand_name', $brand->brands_name) }}" />
                                    @error('brand_name')
                                        <span class="form-text text-muted">
                                            <strong>{{ $message }}</strong>
                                        </span>
                                    @enderror
                                </div>
                            </div>
                        </div>
                        <div class="col-md-4">
                            <div class="row-sm mg-b-20">
                                <div class="form-group">
                                    <label class="az-content-label tx-11 tx-medium tx-gray-600"
                                        for="brands_abbrevation">Brands Abbrevation</label>
                                    <input name="brands_abbrevation" id="brands_abbrevation" class="form-control"
                                        value="{{ old('brands_abbrevation', $brand->brands_abbrevation) }}" />
                                    @error('brands_abbrevation')
                                        <span class="form-text text-muted">
                                            <strong>{{ $message }}</strong>
                                        </span>
                                    @enderror
                                </div>
                            </div>
                        </div>
                        <div class="col-md-4">
                            <div class="row-sm mg-b-20">
                                <div class="form-group">
                                    <label class="az-content-label tx-11 tx-medium tx-gray-600"
                                        for="barnd_status">Status</label>
                                    <select id="barnd_status" name="barnd_status" class="form-control">
                                        <option value="">Select</option>
                                        <option value="1" {{ old('barnd_status', $brand->brands_status) == '1' ? 'selected' : '' }}>Active
                                        </option>
                                        <option value="0" {{ old('barnd_status', $brand->brands_status) == '0' ? 'selected' : '' }}>In-Active
                                        </option>
                                    </select>
                                    @error('barnd_status')
                                        <span class="form-text text-muted">
                                            <strong>{{ $message }}</strong>
                                        </span>
                                    @enderror
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="row">
                        <div class="col-md-4">
                            <div class="row-sm mg-b-20">
                                <div class="form-group">
                                    <label class="az-content-label tx-11 tx-medium tx-gray-600">Brand Logo</label>
                                    <input type="file" name="brand_logo" id="brand_logo" class="form-control" />
                                    @error('brand_logo')
                                        <span class="form-text text-muted">
                                            <strong>{{ $message }}</strong>
                                        </span>
                                    @enderror
                                    @if ($brand->brands_logo)
                                        <img src="{{ asset('uploads/brand_images/' . $brand->brands_logo) }}" alt="Brand Logo" width="100" class="mt-2">
                                    @endif
                                </div>
                            </div>
                        </div>
                    </div>

                    <button type="submit" class="btn btn-az-primary btn-block mt-2" style="float: right">Update</button>
                </form>
            </div>
        </div>
    </div><!-- end of main-content -->
@endsection
