前提・実現したいこと
LaravelのApi開発においてフロントエンドで、Carbonエラーが出ます。
発生している問題・エラーメッセージ
[2022-03-10 09:50:14] staging.ERROR: DateTime::__construct() expects parameter 1 to be string, array given (View: /data/html/resources/views/publishing_schedule/show.blade.php) {"userId":"","email":"","request_method":"GET","request_url":"","headers":{"adduser":["N"],"cookie":["XSRF-TOKEN=eyJpdiI6InZUVjlYaVE0NHVUMUNFQ2RQeERqUEE9PSIsInZhbHVlIjoiYTR2c1VOa3VnbnI2NlJSWlE2cUZVMHJHMnhzOVwvb2dueTlZeE01TW9rWDVEaXQwdjJiQ3J1aTVKMFB3NUFPd1QiLCJtYWMiOiJkMDQyNzQ5MjBmMzgxYjMwMWRkNmY2ZGVkMzI2ZjM5NmIxNmM4ZGZiYzBlYzFlMGI0YTc4MDIzYWNmNjVjM2FhIn0%3D; fox_session=eyJpdiI6IjRpU2hIMlRkR1wvVVVXTWxkV2Y3MWVBPT0iLCJ2YWx1ZSI6InUxRE84RFlOalVRQm5OZGJRVnBRNEY3SW1weHVFR0pjdHF6R1wvUmtwVVNSK1BqNjNOaXJzN2FBNHBxb1pkQkJDIiwibWFjIjoiNTQ0ZTY1Mzc2OWU4YzM3OTIxODQ1ZWNiY2U1NmVmNmE5YjM3OTYxZTE5ZGY1YTZmOTY0NzlkNTdlODUxNzJjYSJ9"],"connection":["keep-alive"],"accept-encoding":["gzip, deflate, br"],"accept-language":["ko-KR,ko;q=0.9"],"qualityplayer":["N"],"user-agent":["Mozilla/5.0 (iPhone; CPU iPhone OS 15_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148"],"api-user-agent":["LF_APP_iOS:phone/2.6.5/iPhone14,5/iOS:15.3"],"showpopup":["N"],"webviewheight":["750.3333333333334"],"api-locale":["ko_KR"],"webviewwidth":["390.0"],"pushstatus":["N"],"accept":["text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"],"amount":["$19.99"],"loginstatus":["N"],"authorization":["Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJodHRwczpcL1wvYXBpcy5saXR0bGVmb3guY29tXC9hcGlcL3YxXC9zdHVkeS1sb2dcL3N1bW1hcnlcL2J5LXRlcm0iLCJpYXQiOjE2NDY4NzA3MTIsImV4cCI6MTY0OTQ2MjcxMiwibmJmIjoxNjQ2ODcwNzEyLCJqdGkiOiJoOTJvU1JUekxLY0t3c2UyIiwic3ViIjoiVTIwMTgwMzIyMTEzNTUyMDQ1NiIsInBydiI6IjIzYmQ1Yzg5NDlmNjAwYWRiMzllNzAxYzQwMDg3MmRiN2E1OTc2ZjciLCJhdXRoX2tleSI6IjM0MTYwODIyOTkwMzg2NzUiLCJjdXJyZW50X3VzZXJfaWQiOiJVMjAxODAzMjIxMTM1NTIwNDU2IiwiZXhwaXJlX2RhdGUiOjE2ODU3NTk0NDB9.OwVWmectqoTmjk3jL0ECCNNHDH1U_ulbFdH6e7MTqXrhCYufdsiwryA0XDSvwZ4ubQ97zkYZh3dP9I_3d_i2ig"],"host":["apis.littlefox.com"],"content-length":[""],"content-type":[""]},"inputs":[],"exception":"[object] (ErrorException(code: 0): DateTime::__construct() expects parameter 1 to be string, array given (View: /data/html/resources/views/publishing_schedule/show.blade.php) at /data/html/vendor/nesbot/carbon/src/Carbon/Carbon.php:548, Symfony\\Component\\Debug\\Exception\\FatalThrowableError(code: 0): DateTime::__construct() expects parameter 1 to be string, array given at /data/html/vendor/nesbot/carbon/src/Carbon/Carbon.php:548)
該当のソースコード
show.blade.php
@extends('layouts.default') @section('main') <div id="wrapper" class="schedule"> <div class="container"> <div class="calendar_month"> <span class="btn"> @if ($selected_date >= \LFLocalization::setTimezoneDate(now())->startOfMonth()) <a href="{{ URL::current() }}?{{ http_build_query(['year' => $selected_date->copy()->subMonth()->year, 'month' => $selected_date->copy()->subMonth()->month]) }}"> <img src="https://cdn.littlefox.com/app/common/images/btns/btn_arrow_cal_l.png" alt=""/> </a> @endif </span> <span class="month">{{ \LFLocalization::lang('webview_calendar_year_month',[$selected_year, Session::get('api_locale') === 'en_US' ? \Carbon\Carbon::parse($selected_date)->format('F') : $selected_month]) }} </span> <span class="btn"> @if ($selected_date < \LFLocalization::setTimezoneDate(now())->startOfMonth()) <a href="{{ URL::current() }}?{{ http_build_query(['year' => $selected_date->copy()->addMonth()->year, 'month' => $selected_date->copy()->addMonth()->month]) }}"> <img src="https://cdn.littlefox.com/app/common/images/btns/btn_arrow_cal_r.png" alt=""/> </a> @endif </span> </div> <div class="schedule_wrap"> @component('components.calendar', [ 'data' => $publishing_schedules, 'week_yn' => 'N', 'selected_year' => $selected_year, 'selected_month' => $selected_month, ]) @endcomponent <div class="t_hide inner"> <ul> @foreach($publishing_schedules as $publishing_schedule) @if ($publishing_schedule['open_date'] === \LFLocalization::setTimezoneDate(now())->toDateString() || (\LFLocalization::setTimezoneDate(now())->isWeekend() && (\LFLocalization::setTimezoneDate(now())->subDay()->toDateString() === $publishing_schedule['open_date'] || \LFLocalization::setTimezoneDate(now())->subDays(2)->toDateString() === $publishing_schedule['open_date']))) <li class="today"> @elseif ($publishing_schedule['open_date'] > \LFLocalization::setTimezoneDate(now())->toDateString()) <li> @else <li class="past"> @endif <div class="date"> <p>{{ \Carbon\Carbon::parse($publishing_schedule['open_date'])->day }}</p> <p class="day">{{ \LFLocalization::lang('webview_calendar_day_of_the_week_'.strtolower(\Carbon\Carbon::parse($publishing_schedule['open_date'])->format('l'))) }}</p> </div> <div class="info"> <p class="level">{{ \LFLocalization::lang('webview_publishing_schedule_level', [$publishing_schedule['level']]) }}</p> <p class="title">{{ $publishing_schedule['name'] . (isset($publishing_schedule['sub_name']) ? (' : '.$publishing_schedule['sub_name']) : '') }}</p> </div> </li> @endforeach </ul> </div> </div> </div> </div> @endsection
試したこと
<p>{{ \Carbon\Carbon::parse($publishing_schedule['open_date'])->day }}</p> この行でデバッグして、変数の中身が確認できないことを確認した。が、ここをどう変えればいいのかわからない。補足情報(FW/ツールのバージョンなど)
Laravel5.7, MariaDB10.3
まだ回答がついていません
会員登録して回答してみよう