Marlon's Blog

记录生活、技术中的二三事.


  • Home

  • Archives

  • Tags

  • Bio

Laravel 模型数据获取

Published at: 2015-02-12   |   Reading: 90 words ~1min

laravel中总模型可以直接转数组

在今天立哥review代码的时候提出来的.

原代码:

1
2
3
4
5
6
7
8
$bmlist  = Appointment::all();
$baoming = [];

foreach ($bmlist as $bm) {
    $baoming[] = $bm->toArray();
}

return $baoming;

改进后的代码:

1
2
$baoming = Appointment::all()->toArray();
return $baoming;

我只想深深说句 fuck!.

#laravel#
  • Author: Marlon Fan
  • Link: https://www.marlon.life/2015/02/12/laravel-%E6%A8%A1%E5%9E%8B%E6%95%B0%E6%8D%AE%E8%8E%B7%E5%8F%96/
  • License: All articles in this blog are licensed under CC BY-NC-ND 4.0 unless stating additionally.
自己在支付业务上的一次失误.
ubuntu 14.04长期支持版本 163源
Marlon Fan

Marlon Fan

宁静致远

48 Blogs
30 Tags
Homepage GitHub Twitter Zhihu
Friends
    过往云烟
© 2008 - 2024 Marlon Fan. All rights reserved. 晋ICP备20002733号-1
0%