I am using laravel 5.4 and using nWidart/laravel-modules to implement the module concept.
->Created a controller ,via that controller i called a job using jobs concept in laravel i wrote a post method , first i capture that in controller then sent the request array to job for inserting inside the table the process is working fine and if i print the result in jobs the object is printing successfully but when i return that to the controller its showing as "0"
-->then i tried to return a normal string still its showing 0 as responce in controller
my Controller
public function store(Request $request)
{
$user = dispatch(new CheckJob($request));
return $user;
}
My Job
public function __construct($requestParams)
{
$this->id = isset($requestParams['id']) ? $requestParams['id'] : null;
$this->firstName = isset($requestParams['firstName']) ? $requestParams['firstName'] : null;
$this->lastName = isset($requestParams['lastName']) ? $requestParams['lastName'] : null;
$this->email = isset($requestParams['emailId']) ? $requestParams['emailId'] : null;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
//
$user = User::firstOrNew(array('id' => $this->id));
$user->first_name = $this->firstName;
$user->last_name = $this->lastName;
$user->email = $this->email;
$user->save();
return $user;
}
When i print $user in controller i get "0" as output