bosnadev / repository

Laravel Repositories is a package for Laravel 5 which is used to abstract the database layer. This makes applications much easier to maintain.

Home Page:https://bosnadev.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable Create Record With Beanstalkd Queue

fer-ri opened this issue · comments

Hi

do you ever face problem that you cant insert/create any record when queue driver set as beanstalkd ?

i always got

Trying to get property of non-object 

Seems like $this->model got undefined and error above got triggered when execute this line

return $this->model->create($data);

my code is pretty simple

<?php

// controller
        $this->dispatch(
            new \Modules\Accounting\Jobs\HitungAdministrasiSimpanan('fa108a98-cd89-402e-b60f-bb1b039c2606')
        );

// job
        $transactionRepository = app()->make(TransactionRepository::class);

        // .. rest code ...

        $transactionRepository->create([
                'reference'   => 'SLUG',
                'nominal'     => 0,
                'description' => 'BLANK',
            ]);

But when queue driver back to sync then everything is ok ..

Any idea?

Thanks

Hey, if you're using an up to date laravel then the create method in Illuminate\Database\Query is now called "insert",
just change the method name in your repository abstract class and in your repository interface to insert instead of create.
then just call insert instead of create:
$transactionRepository->insert([
'reference' => 'SLUG',
'nominal' => 0,
'description' => 'BLANK',
]);

ah my bad this is an old issue that already solved .. sorry for bothering you :)