回答編集履歴

2

変数名変更

2015/06/25 09:24

投稿

icham
icham

スコア559

test CHANGED
@@ -8,19 +8,19 @@
8
8
 
9
9
  $this->set('collection', $this->Report->find('count'));
10
10
 
11
- $timelines = $this->Report->find('all', array('order' => array('created' => 'DESC')));
11
+ $reportList = $this->Report->find('all', array('order' => array('created' => 'DESC')));
12
12
 
13
- $this->set('res', $this->formattedTimeline($timelines));
13
+ $this->set('res', $this->formattedReportList($reportList));
14
14
 
15
15
  }
16
16
 
17
17
 
18
18
 
19
- private function formattedTimeline($timelines) {
19
+ private function formattedReportList($reportList) {
20
20
 
21
- if (count($timelines) === 0) {
21
+ if (count($reportList) === 0) {
22
22
 
23
- return $timelines;
23
+ return $reportList;
24
24
 
25
25
  }
26
26
 
@@ -28,15 +28,15 @@
28
28
 
29
29
  $result = array();
30
30
 
31
- foreach ($timelines as $line) {
31
+ foreach ($reportList as $line) {
32
32
 
33
- $timeline = $line['Report'];
33
+ $report = $line['Report'];
34
34
 
35
- if ($timeline['status'] == 0){
35
+ if ($report['status'] == 0){
36
36
 
37
37
  $status = '未処理';
38
38
 
39
- }else if($timeline['status'] == 1){
39
+ }else if($report['status'] == 1){
40
40
 
41
41
  $status = '処理済み';
42
42
 
@@ -44,13 +44,13 @@
44
44
 
45
45
  $result[] = array(
46
46
 
47
- 'id' => $timeline['id'],
47
+ 'id' => $report['id'],
48
48
 
49
49
  'status' => $status,
50
50
 
51
- 'modified' => $timeline['modified']->toDateTime()->format('Y-m-d H:i:s'),
51
+ 'modified' => $report['modified']->toDateTime()->format('Y-m-d H:i:s'),
52
52
 
53
- 'created' => $timeline['created']->toDateTime()->format('Y-m-d H:i:s'),
53
+ 'created' => $report['created']->toDateTime()->format('Y-m-d H:i:s'),
54
54
 
55
55
  );
56
56
 

1

説明の追加

2015/06/25 09:24

投稿

icham
icham

スコア559

test CHANGED
@@ -1,6 +1,6 @@
1
1
  コントローラ内で処理するのであれば、以下のように別途フォーマットするメソッドを通してはいかがでしょうか?
2
2
 
3
-
3
+ viewは、フォーマットして得た値を表示するように修正が必要になります。
4
4
 
5
5
  ```lang-PHP
6
6
 
@@ -71,3 +71,7 @@
71
71
  好ましくないとは思いますが、おそらくシステム的に登録した値ですよね?
72
72
 
73
73
  それであればセキュリティ上うんぬんというのは理由がよく分からないですね。
74
+
75
+
76
+
77
+ ※ 動作の確認はしてません。