vendredi 1 septembre 2017

Exception Serialization of 'Closure' is not allowed in Queue.php (line 127)

I have this situation where I would have multiple post requests in a single page. The user is supposed to search for affixes (prefix, infix, suffix) so I made 3 search bars for each of them. I finally(?) found a solution to the problem, but another problem popped up and I have no idea what might have caused it.

I am getting this error:

(1/1) Exception
   Serialization of 'Closure' is not allowed
   in Queue.php (line 127)
   at serialize(object(getPSearch))
   in Queue.php (line 127)
   at Queue->createObjectPayload(object(getPSearch))
   in Queue.php (line 108)
   at Queue->createPayloadArray(object(getPSearch), '', null)
   in Queue.php (line 86)
   at Queue->createPayload(object(getPSearch), '', null)
   in SyncQueue.php (line 37)
   at SyncQueue->push(object(getPSearch))
   in Dispatcher.php (line 184)
   at Dispatcher->pushCommandToQueue(object(SyncQueue), object(getPSearch))
   in Dispatcher.php (line 159)
   at Dispatcher->dispatchToQueue(object(getPSearch))
   in Dispatcher.php (line 73)
   at Dispatcher->dispatch(object(getPSearch))
   in DispatchesJobs.php (line 17)
   at Controller->dispatch(object(getPSearch))
   in HomeController.php (line 42)
   at HomeController->findAction(object(Request))

My HomeController, findAction function:

public function findAction(Request $request){
        if ($request->has('psearch')) {
            return $this->dispatch(new \App\Jobs\getPSearch($request));
        } elseif ($request->has('isearch')) {
            return $this->dispatch(new \App\Jobs\getISearch($request));
        } elseif ($request->has('ssearch')) {
            return $this->dispatch(new \App\Jobs\getSSearch($request));
        }
        return 'no action found';
    }

My getPSearch, getISearch, getSSearch jobs (they have somewhat same functionalities but different variables):

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

public function handle()
{
    $data = $this->data;
    $prefixes = DB::table('circumfixes')->select('*')->distinct()->where('prefix', '=', $data.'-')->get();
    $infixes=DB::table('infixes')->select('*')->distinct()->get();
    $suffixes=DB::table('suffixes')->select('*')->distinct()->get();

    $affixes=[
        'prefixes' => $prefixes,
        'infixes' => $infixes,
        'suffixes' => $suffixes
    ];
    return view('home', $affixes);
}

My routes for them:

Route::get('/home', 'HomeController@index')->name('home');
Route::post('/home', 'HomeController@findAction');

I tried to search how to solve the problem online but I can't seem to find a solution that I could understand. I am new to Laravel, so I may have difficulties in understanding some points but I am eager to learn it! I hope I could find an answer.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire