0
私は関係Laravel 5を繰り返しID
関係/モデルに二重のidに問題があります。
public function pp(){
return $this->hasMany('App\Pp',"pfield","id")
->join('other',"other.id",'=','Pp.product');
}
コントローラ:
$pp = $psmf->pp;
print_r($pp);
私は二度IDを持っている必要がありますが、私はできるがテーブルは次のようになります。
|id|name|sth1|sth2
|1 |asfa|afsf|faxc
.................
next table:
|id|sth3|sth4
|1 |asdg|afsg
|2 |awer|qerq
|3 |retr|gdfg
私はこのような方法でデータを表示したいと思います。
[original:protected] => Array
(
[id] => 1
[name] => asfa
[sth1] => afsf
[sth2] => faxc
[id] => 1
[sth3] => asdg
[sth4] => afsg
),
Array
(
[id] => 1
[name] => asfa
[sth1] => afsf
[sth2] => faxc
[id] => 2
[sth3] => awer
[sth4] => qerq
),
Array
(
[id] => 1
[name] => asfa
[sth1] => afsf
[sth2] => faxc
[id] => 3
[sth3] => retr
[sth4] => gdfg
)
基本的には、2回のテーブルIDを使用する必要があります。残念ながら、この方法ではすべてのデータ・ウェルがIDに上書きされます。
select id as "first_id",name,sth1,sth2,id as "Sec_id",sth3,sth4
を、このように私はあなたが私を助けることができるIDを2回
を使用することができます:単純なSQLコードで 、それを行うために必要なもの、それは次のようになりますか? >最初/取得() -