laravel queue: array_merge(): Expected parameter 2 to be an array, int given

1.2k Views Asked by At

i will use from laravel queue but return this error:

laravel queue: array_merge(): Expected parameter 2 to be an array, int given

ScanController:

<?php

namespace App\Http\Controllers;

use App\Asset;
use App\AssetGroup;
use Illuminate\Http\Request;
use App\Jobs\ProcessScan;

class ScanController extends Controller
{
    public function index(Request $request)
    {
//        $assets = Asset::where('group_id', $request->group_id)->get()->pluck('name')->implode(',');
//        $client = new \GuzzleHttp\Client();
//        $res = $client->get("https://cve-search.iicrai.org/api/search/$assets", ['auth' =>  ['user', 'password123']]);
//        $allData = json_decode($res->getBody(), true);
//        $allData = $allData['data'];

        dispatch(new ProcessScan());
        return view('scan.index', compact('allData'));
    }
}

Jobs/ProcessScan:

<?php

    namespace App\Jobs;
    
    use App\Asset;
    use Illuminate\Bus\Queueable;
    use Illuminate\Contracts\Queue\ShouldQueue;
    use Illuminate\Foundation\Bus\Dispatchable;
    use Illuminate\Queue\InteractsWithQueue;
    use Illuminate\Queue\SerializesModels;
    
    class ProcessScan implements ShouldQueue
    {
        use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
    
        /**
         * Create a new job instance.
         *
         * @return void
         */
        public function __construct()
        {
    
        }
    
        /**
         * Execute the job.
         *
         * @return void
         */
        public function handle()
        {
            $assets = Asset::where('group_id', $request->group_id)->get()->pluck('name')->implode(',');
            $client = new \GuzzleHttp\Client();
            $res = $client->get("https://cve-search.iicrai.org/api/search/$assets", ['auth' =>  ['user', 'password123']]);
            $allData = json_decode($res->getBody(), true);
            $allData = $allData['data'];
        }
    }

how to resolve this problem? ..........................................................................

1

There are 1 best solutions below

0
On

update query like this

$assets = Asset::where('group_id', $request->group_id)->pluck('name')->get()->implode(',');