私のLaravel 5.1アプリケーションでは、Subscriptionの機能があります。ユーザーが.. 6ヶ月間2016年10月のサブスクリプションを作るので、配列は次のようになります:月の表示と条件に基づく年
私が..シナリオを探しています何ある程度作業ではなく、私が示しています上記の配列は、わずか1ヶ月である
[
"subscription_months" => 6
"subscription_start_month" => "01-10-2016" // <-- will be carbon instance
"subscription_end_month => "31-03-2017" // <-- will be carbon instance
"monthName" => "October"
]
..配列の5つの以上の要素があるでしょう
私は追加したい、で欲しいYear
後monthName
これはこういう風に見えます。
[
[
"monthName" => "October, 2016" // <-- for 1st month
]
[
"monthName" => "November, 2016" // <-- for 2nd month
]
[
"monthName" => "December, 2016" // <-- for 3rd month
]
[
"monthName" => "January, 2017" // <-- for 4th month
]
[
"monthName" => "February, 2017" // <-- for 5th month
]
[
"monthName" => "March, 2017" // <-- for 6th month
]
]
私がこれまで試してみましたコードは次のとおりです。
$startMonthForMixed = $invoice->subscription_start_date->month;
for($i = 0; $i < $invoice->subscription_months; $i++) {
$convertedInvoices[] = [
'id' => $invoice->id,
'order_code' => $invoice->order_code,
'order_type' => 'Mixed - Subscription',
'subscription_months' => $invoice->subscription_months,
'subscription_start_month' => $invoice->subscription_start_date,
'subscription_end_month' => $invoice->subscription_end_date,
'monthName' => date("F", mktime(0, 0, 0, $startMonthForMixed, 01)) . ", " . Carbon::now()->addYear()
];
$startMonthForMixed++;
}
誰がこれを助けることはできますか?前もって感謝します。
'date(" F、Y "'? – splash58
他のすべてのプロパティと共にmonthNameプロパティを必要とするか、 – trincot
@trincot他のすべてのプロパティと一緒にmonthNameプロパティが必要です..しかし、それらのいずれかが私のために働くでしょう。 –