これはしばらくの間私を悩ませてきたものであり、今日、まともな答えが見つからなかったので、共有したいと思った比較的簡単な解決策を見つけました.
DB ラッパー用に次のコードがあります。
function find($id) {
//Fetch the results
//Put the results into an array
return (object) $results;
}
だから私はできる:
$result = DB::find(1);
echo $result->name; #=> Hello world
しかし、その新しい結果にメソッドを割り当てることができる必要があります。この場合to_json