Michael Michael - 8 months ago 46
PHP Question

Trying to get property of non-object in Job Laravel

I'm trying to create job to register users and tried to follow Jeffrey's video but looks like dispatchfrom is removed for some reason. This is what i'm trying to do now:

This is my controller:

public function PostSignUp(Request $request)

dispatch(new RegisterUser($request->all()));
return 'done';


This is my job:

namespace App\Jobs;

use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;

class RegisterUser implements ShouldQueue
use InteractsWithQueue, Queueable, SerializesModels;

protected $request;

* Create a new job instance.
* @param $request
* @return void
public function __construct($request)
$this->request = $request;

* Execute the job.
* @return void
public function handle()
$email = $this->request->email;
var_dump('I should register user with email:' . $email);

I also tried to put

instead of

but then i get

Serialization of 'Closure' is not allowed

And now I'm getting
Trying to get property of non-object error.
Is this good way to pass whole request to job ? Should i do it some other way ?

Answer Source

try with input()