Laravel系列 - 展平不起作用

时间:2017-03-02 14:13:27

标签: php json laravel laravel-5 laravel-collection

我有学生数据库,其中我只有3列(id,name,dob)。我写了简单的选择查询,

return DB::table('student')->get(['id','name','dob']);

我收到了回复,

[{"id":1,"name":"Kaylah Hayes","dob":"1993-02-24"},{"id":2,"name":"Janis Casper Sr.","dob":"1994-07-11"}]

但我只需要这样的价值,

[{1,"Kaylah Hayes","1993-02-24"}, {2,"Janis Casper Sr.","1994-07-11"}]

我尝试过使用flatten方法,

return DB::table('student')->get(['id','name','dob'])->flatten();

但它不起作用。

感谢。

1 个答案:

答案 0 :(得分:6)

您可以尝试以下方式:

$('mySwiperContainer').on('appear', function(event, $all_appeared_elements) {
  // this element is now inside browser viewport
  var mySwiper = new Swiper ('.swiper-container', {
    // Optional parameters
    pagination: '.swiper-pagination',
    paginationClickable: true,
    nextButton: '.swiper-button-next',
    prevButton: '.swiper-button-prev',
    spaceBetween: 0,
    parallax: true,
    autoplay: 5000,
    speed: 800,
    autoplayDisableOnInteraction: false
  }) 
});

希望这有帮助!