UserテーブルとPhotoテーブルがあり、Photoテーブルのフィールドにuser_idを作り1:Nでリレーションを張っています。
ModelのPhoto.phpで下記のようなデータを取得しているのですが、userのidを送信したくありません。
どのようにコーディングすべきでしょうか。
{ "id": 1, "name": "panda", "category": "animal", "detail": "hogehoge", "user_id": 1, "user": { "id": 1, // ←これを消したい "name": "takahashi", "address": "india" } }
//PhotoRepository.php public function getPhotoById($id) { $photo = $this->photo->findOrFail($id); $photo->user; return $photo; }
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。