Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/rest/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Laravel 5.2 将对象数组转换为整数数组_Laravel 5.2 - Fatal编程技术网

Laravel 5.2 将对象数组转换为整数数组

Laravel 5.2 将对象数组转换为整数数组,laravel-5.2,Laravel 5.2,我需要将以下对象数组转换为laravel中的整数数组。下面是我需要转换为数组的代码 $idArray = DB::table('booking_header') ->select('booking_header.id') ->where('booking_header.parent_booking_id', $oldId) ->get(); 我用勇气试过了。但它不起作用。有人能帮我吗?使用pull()代替get()来获取一个

我需要将以下对象数组转换为laravel中的整数数组。下面是我需要转换为数组的代码

  $idArray = DB::table('booking_header')
        ->select('booking_header.id')
        ->where('booking_header.parent_booking_id', $oldId)
        ->get();
我用勇气试过了。但它不起作用。有人能帮我吗?

使用pull()代替get()来获取一个简单的ID数组

$idArray = DB::table('booking_header')
    ->select('booking_header.id')
    ->where('booking_header.parent_booking_id', $oldId)->pluck('booking_header.id');
调用成员函数all()on array error将导致我看到,laravel 5.2中的pull()返回简单数组(而不是集合)。在这种情况下,您不需要全部使用()我已经测试过Pull()-就像我提到的一样,工作正常。在其他情况下,您的查询中出现了错误。确保您的where条件正确。