0
我有表格:operations
,remarks
和adjustments
。Laravel雄辩从第二级表中获取数据
operations
:
| id | user_id | operation | start_date | end_date |
| 1 | 2 | opeartion1 | 1/1/16 | 5/5/16 |
| 2 | 2 | opeartion2 | 1/1/16 | 5/5/16 |
remarks
:
| id | user_id | operation_id | remarks |
| 10 | 4 | 1 | remarks1 new |
| 13 | 4 | 2 | remarks22new |
adjustments
:
| id | remarks_id | user_id | before | after | created_at | updated_at |
|:--:|:----------:|:-------:|:----------------------:|:----------------------------:|:-------------------:|:-------------------:|
| 1 | 10 | 6 | {"remarks":"remarks1"} | | {"remarks":"remarks1 new"} | 0000-00-00 00:00:00 | 0000-00-00 00:00:00 |
| 2 | 13 | 7 | {"remarks":"remarks1"} | | {"remarks":"remarks1 new"} | 0000-00-00 00:00:00 | 0000-00-00 00:00:00 |
我想从adjustments
表中获取数据,在Operation
特别operation_id
这样控制器的show()
方法:
$history = Adjustment::with('user','remark')->get();
从此我得到的所有行从adjustments
表是这样的:
Jerry Nienow 2016-05-12 07:00:24 {"remarks":"remarks1"} {"remarks":"remarks1 new"}
Jerry Nienow 2016-05-12 07:01:09 {"remarks":"remarks22"} {"remarks":"remarks22new"}
,但我希望有一个特定的operation_id
这样的:
Jerry Nienow 2016-05-12 07:00:24 {"remarks":"remarks1"} {"remarks":"remarks1 new"}
:) :) :)如果你是laravel的专家,请回答这个问题[问题1](https://laracasts.com/discuss/channels/laravel/how-to-display-json-data- more-redable?page = 1#reply-162307) – user3461049
@Ivanko Todorova等待您的答案:([QQ](https://stackoverflow.com/questions/37129211/how-to-display-json-data-readable-这样,对于用户功能于laravel) – user3461049