HEX
Server: LiteSpeed
System: Linux php-prod-3.spaceapp.ru 5.15.0-151-generic #161-Ubuntu SMP Tue Jul 22 14:25:40 UTC 2025 x86_64
User: sarli3128 (1010)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: //home/marketing.cfbon.ru/public_html/resources/views/coffee-shops/edit.blade.php
@extends('layouts.main')

@section('return_btn_url') @include('layouts.return-btn', ['routeName' => 'coffee-shops.index']) @endsection

@section('title', 'Изменить кофейню ' . $shop->address)

@section('content')
    <div class="container mt-3 ms-2">
        <form action="{{ route('coffee-shops.update', $shop->id) }}" method="post" enctype="multipart/form-data">
            <div class="row d-flex">
                <div class="col-md-6">
                    @method('PATCH')
                    @csrf
                    <div class="mb-3">
                        <input type="text" class="form-control @error('number') is-invalid @enderror" name="number" value="{{ old('number', $shop->number) }}" placeholder="Введите номер кофейни">

                        @error('number')<div class="invalid-feedback">{{ $message }}</div>@enderror
                    </div>
                    <div class="mb-3">
                        <input type="text" class="form-control @error('address') is-invalid @enderror" name="address" value="{{ old('address', $shop->address) }}" placeholder="Введите Адрес">

                        @error('address')<div class="invalid-feedback">{{ $message }}</div>@enderror
                    </div>
                    <div class="mb-3">
                        <select class="form-select @error('metro_data') is-invalid @enderror" name="metro_data" id="metro_data">
                            @foreach($metroStations as $metroLine)
                                @foreach($metroLine->stations as $station)
                                    <option value="{{ $station }}" style="color: {{ $metroLine->color }}" data-color="{{ $metroLine->color }}" {{ old('metro_data', $shop->metro_data->name) == $station ? 'selected' : '' }}>
                                        {{ $station }}
                                    </option>
                                @endforeach
                            @endforeach
                        </select>
                        @error('metro_data')<div class="invalid-feedback">{{ $message }}</div>@enderror
                        <div id="color-preview" style="height: 5px; border-radius: 3px; margin-top: 8px; background-color: #ccc; transition: background-color 0.3s;"></div>
                    </div>

                    <div class="mb-3 row g-2">
                        <div class="col-md-6">
                            <input type="text" class="form-control @error('latitude') is-invalid @enderror" name="latitude" value="{{ old('latitude', $shop->latitude) }}" placeholder="Широта">

                            @error('latitude')
                            <div class="invalid-feedback">{{ $message }}</div>
                            @enderror
                        </div>
                        <div class="col-md-6">
                            <input type="text" class="form-control @error('longitude') is-invalid @enderror" name="longitude" value="{{ old('longitude', $shop->longitude) }}" placeholder="Долгота">

                            @error('longitude')
                            <div class="invalid-feedback">{{ $message }}</div>
                            @enderror
                        </div>
                    </div>
                    <div class="mb-3">
                        <input id="phone" type="text" class="form-control @error('phone') is-invalid @enderror" name="phone" value="{{ old('phone', $shop->phone) }}" placeholder="Номер телефона">

                        @error('phone')<div class="invalid-feedback">{{ $message }}</div>@enderror
                    </div>
                    <button type="submit" class="btn btn-danger w-25">Изменить</button>
                </div>
                <div class="col-md-6">
                    <div class="schedule-block p-4 mb-4 rounded shadow-sm border border-light-subtle">
                        <h5 class="mb-3 text-danger">График работы</h5>

                        <div class="mb-3">
                            <label class="form-label">Выберите рабочие дни:</label>
                            <div class="d-flex flex-wrap gap-2">
                                @php
                                    $days = ['ПН', 'ВТ', 'СР', 'ЧТ', 'ПТ', 'СБ', 'ВС'];
                                @endphp

                                @foreach($days as $day)
                                    <div class="form-check">
                                        <input type="checkbox" id="day-{{ $loop->index }}" name="working_days[]" value="{{ $day }}"
                                               class="btn-check"
                                               autocomplete="off"
                                            {{ in_array($day, old('working_days', $shop->working_days)) ? 'checked' : '' }}>
                                        <label class="btn btn-outline-danger" for="day-{{ $loop->index }}">{{ $day }}</label>
                                    </div>
                                @endforeach
                            </div>
                            @error('working_days')
                            <div class="invalid-feedback d-block">{{ $message }}</div>
                            @enderror
                        </div>

                        <div class="mb-3">
                            <div class="row g-2">
                                <div class="col-md-5">
                                    <input type="time" name="worked_start" class="form-control @error('worked_start') is-invalid @enderror" value="{{ old('worked_start', $shop->worked_start) }}">
                                    @error('worked_start')
                                    <div class="invalid-feedback">{{ $message }}</div>
                                    @enderror
                                </div>
                                <div class="col-md-5">
                                    <input type="time" name="worked_end" class="form-control @error('worked_end') is-invalid @enderror" value="{{ old('worked_end', $shop->worked_end) }}">
                                    @error('worked_end')
                                    <div class="invalid-feedback">{{ $message }}</div>
                                    @enderror
                                </div>
                            </div>
                        </div>

                        <hr class="my-4">

                        <div class="mb-3">
                            <label class="form-label">Выберите выходные дни:</label>
                            <div class="d-flex flex-wrap gap-2">
                                @php
                                    $days = ['ПН', 'ВТ', 'СР', 'ЧТ', 'ПТ', 'СБ', 'ВС'];
                                @endphp

                                @foreach($days as $day)
                                    <div class="form-check">
                                        <input type="checkbox" id="weekend_days-{{ $loop->index }}" name="weekend_days[]" value="{{ $day }}"
                                               class="btn-check"
                                               autocomplete="off"
                                            {{ !empty($shop->weekend_days) && in_array($day, old('weekend_days', $shop->weekend_days)) ? 'checked' : '' }}>
                                        <label class="btn btn-outline-secondary" for="weekend_days-{{ $loop->index }}">{{ $day }}</label>
                                    </div>
                                @endforeach
                            </div>
                            @error('weekend_days')
                            <div class="invalid-feedback d-block">{{ $message }}</div>
                            @enderror
                        </div>

                        <div class="mb-3">
                            <div class="row g-2">
                                <div class="col-md-5">
                                    <input type="time" name="weekend_start" class="form-control @error('weekend_start') is-invalid @enderror" value="{{ old('weekend_start', $shop->weekend_start) }}">
                                    @error('weekend_start')
                                    <div class="invalid-feedback">{{ $message }}</div>
                                    @enderror
                                </div>
                                <div class="col-md-5">
                                    <input type="time" name="weekend_end" class="form-control @error('weekend_end') is-invalid @enderror" value="{{ old('weekend_end', $shop->weekend_end) }}">
                                    @error('weekend_end')
                                    <div class="invalid-feedback">{{ $message }}</div>
                                    @enderror
                                </div>
                            </div>
                        </div>
                        <div class="mb-3 mt-2 switch-wrapper">
                            <label class="switch-label">
                                <input type="checkbox" name="is_open"
                                       {{ old('is_open', $shop->is_open ? 'on' : '') == 'on' ? 'checked' : '' }}
                                       class="switch-checkbox @error('is_open') is-invalid @enderror">
                                <span class="switch-slider"></span>
                                <span class="switch-text">Закрыто/Открыто</span>
                            </label>

                            @error('is_open')<div class="invalid-feedback">{{ $message }}</div>@enderror
                        </div>
                    </div>

                </div>
            </div>
        </form>
    </div>
@endsection

@section('scripts')
    @parent
    <script>
        document.addEventListener('DOMContentLoaded', function () {
            const select = document.getElementById('metro_data');
            const colorPreview = document.getElementById('color-preview');

            function updateColorPreview() {
                const selectedOption = select.options[select.selectedIndex];
                const color = selectedOption.getAttribute('data-color');
                if (color) {
                    colorPreview.style.backgroundColor = color;
                }
            }
            updateColorPreview();
            select.addEventListener('change', updateColorPreview);
        });
    </script>
    <script>
        const maskOptions = {
            mask: ["+{7} (000) 000-00-00"],
        }
        function maskCard(elements) {
            elements.forEach((element) => {
                if (element instanceof HTMLElement) {
                    IMask(element, maskOptions);
                }
            });
        }

        const card = document.querySelectorAll("#phone");
        maskCard(card);
    </script>
@endsection