0

I have a problem and after 2hours didn't figure out what's my problem!

I use Queue::before in AppServiceProvider, and I want to check if x value for x user exists in the table don't fire job instantly and add release it after 60 sec ! and again this function check if x value is null job will fire!

Now my problem is in line 4 cant get $data->test->user_id and after event fire, I will get this error!

Undefined property: Illuminate\Broadcasting\BroadcastEvent::$test

but if I use dd($data->test->user_id) I will get user_id correctly !

 Queue::before(function (JobProcessing $event) {
            $jsonpayload = $event->job->payload();
            $data = unserialize($jsonpayload['data']['command']);
            $user = DB::table('users')->where('id','=',$data->test->user_id)->first();
            $pay =  DB::table('donates')->where('user_id','=',$user->id)->where('status','=','0')->first();
            if(!is_null($pay)) {
                $event->job->release(Carbon::now()->addSeconds(60));
            }
        }); 

dd($jsonpayload);

array:10 [
  "uuid" => "329165c3-f8e7-4bd0-814e-74f6f44d1158"
  "displayName" => "App\Jobs\LiveDonate"
  "job" => "Illuminate\Queue\CallQueuedHandler@call"
  "maxTries" => 10
  "maxExceptions" => null
  "delay" => null
  "timeout" => null
  "timeoutAt" => null
  "data" => array:2 [
    "commandName" => "App\Jobs\LiveDonate"
    "command" => "O:19:"App\Jobs\LiveDonate":11:{s:4:"test";O:45:"Illuminate\Contracts\Database\ModelIdentifier":4:{s:5:"class";s:7:"App\Pay";s:2:"id";i:89;s:9:"relations";a:0:{}s:10:"connection";s:5:"mysql";}s:26:"\x00App\Jobs\LiveDonate\x00check";s:8:"shabdola";s
:5:"tries";i:10;s:3:"job";N;s:10:"connection";N;s:5:"queue";N;s:15:"chainConnection";N;s:10:"chainQueue";N;s:5:"delay";N;s:10:"middleware";a:0:{}s:7:"chained";a:0:{}}"
  ]
  "telescope_uuid" => "90892cd3-96c5-4de1-8fae-9718e45e2bcc"
]

What do you think guys? What's my problem?

4

0 回答 0