JSONでモデルリレーションシップを返そうとすると、リレーションシップフィールドが表示されません。私の結果ですJSONのLaravelリターンモデルリレーション
$customer_subscriptions = CustomerSubscription::has("customer")
->has("subscription")
->has("federationDiscipline")
->where("customer_id", "=", $customer_id)
->whereHas("subscription", function($query) use($company_id) {
$query->where("company_id", "=", $company_id);
})
->orderBy("start_date", "asc");
return $customer_subscriptions;
:
[0]=>
array(14) {
["id"]=>
int(2)
["customer_id"]=>
int(1)
["subscription_id"]=>
int(1)
["federation_discipline_id"]=>
int(1)
["start_date"]=>
string(10) "2017-04-01"
["end_date"]=>
string(10) "2017-05-31"
["external_id"]=>
NULL
["notes"]=>
NULL
["created_user_id"]=>
int(1)
["updated_user_id"]=>
NULL
["deleted_user_id"]=>
NULL
["created_at"]=>
string(19) "2017-06-05 07:28:00"
["updated_at"]=>
string(19) "2017-06-05 07:28:00"
["deleted_at"]=>
NULL
}
私は、サブスクリプションのと顧客の関係フィールドは表示されませんそれは私のクエリです。クエリの結果でJSONがAJAXに返される
[OK]を、それが動作します。しかし、私と一緒に使うと、モデルはcustomer/subscription/federationDisciplineなしでCustomerSubscriptionを得ることができます。と一緒に使うことができますか? – Mintendo
はい、両方を使用できます。 –