我如何通过foreach来解决/修复开放时间

时间:2019-02-13 21:05:08

标签: laravel

我想分别显示每个foreach功能的开放时间。

我尝试了不同的代码集,但我坚持做不到。我知道这是非常错误的foreach显示位置正常工作。我只是坚持开放时间 23-37 LocationsController.php

    $open = Location::pluck('open');
    $closed = Location::pluck('closed');

    $openingHours = OpeningHours::create([
        'monday' => ['$open-$closed'],
        'tuesday' => ['$open-$closed'],
        'wednesday' => ['$open-$closed'],
        'thursday' => ['$open-$closed'],
        'friday' => ['$open-$closed'],
        'saturday' => ['$open-$closed'],
        'example' => ['00:00-16:00'],
    ]);

    $page = Page::where('slug', 'locations')->first();
    $locations = Location::paginate(10)->fresh();

17-44 location.blade.php

@foreach($locations as $location)
<div class="strip map_view add_top_20">
<div class="row">
<div class="col-md-12 col-xs-12 strip-cus">
<div class="p-t-5 p-l-15">
<h3 class="location-title capital"><a href="#" class="text-cleo inline bold" style="padding-right:15px;">{{ $location->short_desc }}</a><span class="loc_cleo capital" style="float:right; margin-right:15px;">{{ $location->city }}, {{ $location->country }}</span></h3>
                                    <p class="fs-12 capital">{{ $location->address }}</p>
                                    {{ $location->open }}
                                    {{ $location->closed }}
                                    </p>
                                </div>
                                <ul>
                                    <li>
                                    @if ($openingHours->isOpen())
                                    <span class="loc_open">Open</span>
                                    @else
                                    <span class="loc_closed">Closed</span>
                                    @endif

                                    </li>
                                    <li><a href="{{ $location->phone_link }}" class="text-cleo fs-12 bold">{{ $location->phone_number }}</a></li>
                                </ul>
                            </div>
                        </div>
                    </div>
@endforeach

我的位置数据库包含内部格式为16:00的打开和关闭的列

开放时间正常,但没有达到预期的水平。

0 个答案:

没有答案