1 year ago

#278598

test-img

Göktuğ Ozleyen

Laravel Queue not able to convert class object to string how can i dispatch that?

How can i use dispatch for this situation ?

    use App\Jobs\JRegister;

    $customer = Customer::updateOrCreate(['id' => $userID], $data);
    if ($customer) {
         JRegister::dispatch($customer);
    }

If i run this code laravel.log returns me:

local.ERROR: Connection could not be established with host mailhog :stream_socket_client(): php_network_getaddresses: getaddrinfo failed: nodename nor servname provided, or not known {"exception":"[object] (Swift_TransportException(code: 0):

Same issue on the server so i think it is not on my local issue.

And why does this error occur?

In my JRegister i have these methods.

private function initData($customer)
{
    $company = Company::select(...)->first();
    
    //Another process

    $this->company = $company;
}

public function handle()
{
    $customer = $this->customer;

    echo $customer->firstname;
    $this->initData($customer);
}

public function __construct($customer)
{
    $this->customer = $customer;
}

laravel

laravel-5

queue

dispatcher

laravel-queue

0 Answers

Your Answer

Accepted video resources