Ejemplo n.º 1
0
 /**
  * Display a listing of the resource.
  *
  * @param  Request $request
  *
  * @return Response
  */
 public function index(Request $request)
 {
     // varianta simpla
     $users = User::all()->map(function ($item, $key) {
         $item->links = ['addresses' => 'addresses'];
         return $item;
     });
     return response()->json(['users' => $users]);
     // varianta cu datatables
     return Datatables::of(User::select('*'))->addColumn('links', function ($user) {
         return ['addresses' => 'addresses'];
     })->make(true);
 }
 /**
  * 创建用户事件
  */
 public static function generateUserCreateEvents()
 {
     // 三个虚拟订单自09-15始,设置用户加入时间小于09-15
     \DB::update('UPDATE xb_user SET created_at = \'2015-09-10 12:12:12\' WHERE uid < 11');
     $list = \App\Models\User\User::all();
     foreach ($list as $k => $v) {
         //
         self::getsetEvent($v['created_at'], 'userCreate', ['uid' => $v['uid'], 'truename' => $v['truename'], 'phone' => $v['phone'], 'identity' => $v['identity'], 'created_at' => $v['created_at'] . '']);
     }
     \App\Models\User\User::where('uid', '>', 0)->delete();
     return;
 }