配列の操作方法を理解する上で問題があります。注文の価格と詳細が返されたところで請求書を作成しようとしていますが、そのほとんどは作業していますが、注文の項目。これまでの私のコードは次のようになります。OctoberCMS配列を使って作業する
public $items;
public function prepareVars() {
$this->items = $this->items();
}
public function items() {
$plates = Db::table('orders')->where('quote_no', $this->quoteNo())->value('total_plate_qty');
$hires = Db::table('orders')->where('quote_no', $this->quoteNo())->value('req_hires');
$hardcopy = Db::table('orders')->where('quote_no', $this->quoteNo())->value('req_hardcopy_proof');
$pdfproof = Db::table('orders')->where('quote_no', $this->quoteNo())->value('req_pdf_proof');
if ($plates < 1) {
$plates = "Total Plates:" . $plates;
} else {
$plates = "";
}
if ($pdfproof === 'yes') {
$pdfproof = 'PDF Proof @ R25.00';
} else {
$hires = '';
}
if ($hires === 'yes') {
$hires = 'HiRes PDF @ R50.00';
} else {
$hires = '';
}
if ($hardcopy === 'yes') {
$hardcopy = 'HardCopy Proof @ R150.00';
} else {
$hardcopy = '';
}
return Response::json([
'pdf' => $pdfproof,
'hires' => $hires,
'hardcopy' => $hardcopy,
'plates' => $plates
]);
}
これは、このように私のデータベース内のデータを保存している:
HTTP/1.0 200 OK
Cache-Control: no-cache
Content-Type: application/json
Date: Thu, 02 Nov 2017 08:26:11 GMT
{"pdf":"PDF Proof @ R25.00","hires":"HiRes PDF @ R50.00","hardcopy":"HardCopy Proof @ R150.00","plates":""}
そして、フロントエンドに私は小枝機能{%に対して%}を使用していますし、
{% set items = __SELF__.items %}
{% for item in items %}
<td>{{ item.pdf }}</br>{{ item.hires }}</br>{{ item.hardcopy }}</br>{{ item.plates }}</br></td>
{% endfor %}
しかし、これはフロントエンドで何も返されません。
私はそれをすべて間違ってやっているように私は、バックエンドのDEVとのnoob午前、これは感じている:大幅
私はOctoberCMSを使用していませんが、この '{%set items = json_decode(__ SELF __。items)%}'のような項目jsonをデコードしてテストする必要があると思います! – Maraboc