Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call to a member function beginTransaction() on null @ Illuminate/Database/Concerns/ManagesTransactions #2

Open
ux-engineer opened this issue Jun 10, 2017 · 0 comments

Comments

@ux-engineer
Copy link

Getting this kind of error out of the box when using Laravel Spark.

[2017-06-09 22:10:12] local.ERROR: Symfony\Component\Debug\Exception\FatalThrowableError: Call to a member function beginTransaction() on null in /home/vagrant/Code/leadwise-laravel/vendor/laravel/framework/src/Illuminate/Database/Concerns/ManagesTransactions.php:108
Stack trace:
#0 /home/vagrant/Code/leadwise-laravel/vendor/laravel/framework/src/Illuminate/Database/Concerns/ManagesTransactions.php(92): Illuminate\Database\Connection->createTransaction()
#1 /home/vagrant/Code/leadwise-laravel/vendor/laravel/framework/src/Illuminate/Database/Concerns/ManagesTransactions.php(23): Illuminate\Database\Connection->beginTransaction()
#2 /home/vagrant/Code/leadwise-laravel/vendor/laravel/framework/src/Illuminate/Database/DatabaseManager.php(324): Illuminate\Database\Connection->transaction(Object(Closure))
#3 /home/vagrant/Code/leadwise-laravel/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(221): Illuminate\Database\DatabaseManager->__call('transaction', Array)
#4 /home/vagrant/Code/leadwise-laravel/spark/src/Interactions/Auth/Register.php(32): Illuminate\Support\Facades\Facade::__callStatic('transaction', Array)
#5 [internal function]: Laravel\Spark\Interactions\Auth\Register->handle(Object(Laravel\Spark\Http\Requests\Auth\StripeRegisterRequest))
#6 /home/vagrant/Code/leadwise-laravel/spark/src/Configuration/CallsInteractions.php(56): call_user_func_array(Array, Array)
#7 /home/vagrant/Code/leadwise-laravel/spark/src/Http/Controllers/Auth/RegisterController.php(59): Laravel\Spark\Spark::interact('Laravel\\Spark\\C...', Array)
#8 [internal function]: Laravel\Spark\Http\Controllers\Auth\RegisterController->register(Object(Laravel\Spark\Http\Requests\Auth\StripeRegisterRequest))
#9 /home/vagrant/Code/leadwise-laravel/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(55): call_user_func_array(Array, Array)
#10 /home/vagrant/Code/leadwise-laravel/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(44): Illuminate\Routing\Controller->callAction('register', Array)
#11 /home/vagrant/Code/leadwise-laravel/vendor/laravel/framework/src/Illuminate/Routing/Route.php(203): Illuminate\Routing\ControllerDispatcher->dispatch(Object(Illuminate\Routing\Route), Object(Laravel\Spark\Http\Controllers\Auth\RegisterController), 'register')
#12 /home/vagrant/Code/leadwise-laravel/vendor/laravel/framework/src/Illuminate/Routing/Route.php(160): Illuminate\Routing\Route->runController()
#13 /home/vagrant/Code/leadwise-laravel/vendor/laravel/framework/src/Illuminate/Routing/Router.php(574): Illuminate\Routing\Route->run()
#14 /home/vagrant/Code/leadwise-laravel/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(30): Illuminate\Routing\Router->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#15 /home/vagrant/Code/leadwise-laravel/app/Http/Middleware/RedirectIfAuthenticated.php(24): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#16 /home/vagrant/Code/leadwise-laravel/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): App\Http\Middleware\RedirectIfAuthenticated->handle(Object(Illuminate\Http\Request), Object(Closure))
#17 /home/vagrant/Code/leadwise-laravel/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#18 /home/vagrant/Code/leadwise-laravel/spark/src/Http/Middleware/CreateFreshApiToken.php(40): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#19 /home/vagrant/Code/leadwise-laravel/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): Laravel\Spark\Http\Middleware\CreateFreshApiToken->handle(Object(Illuminate\Http\Request), Object(Closure))
#20 /home/vagrant/Code/leadwise-laravel/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#21 /home/vagrant/Code/leadwise-laravel/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(41): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#22 /home/vagrant/Code/leadwise-laravel/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): Illuminate\Routing\Middleware\SubstituteBindings->handle(Object(Illuminate\Http\Request), Object(Closure))
#23 /home/vagrant/Code/leadwise-laravel/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#24 /home/vagrant/Code/leadwise-laravel/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(65): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#25 /home/vagrant/Code/leadwise-laravel/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): Illuminate\Foundation\Http\Middleware\VerifyCsrfToken->handle(Object(Illuminate\Http\Request), Object(Closure))
#26 /home/vagrant/Code/leadwise-laravel/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#27 /home/vagrant/Code/leadwise-laravel/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#28 /home/vagrant/Code/leadwise-laravel/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): Illuminate\View\Middleware\ShareErrorsFromSession->handle(Object(Illuminate\Http\Request), Object(Closure))
#29 /home/vagrant/Code/leadwise-laravel/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#30 /home/vagrant/Code/leadwise-laravel/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(64): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#31 /home/vagrant/Code/leadwise-laravel/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): Illuminate\Session\Middleware\StartSession->handle(Object(Illuminate\Http\Request), Object(Closure))
#32 /home/vagrant/Code/leadwise-laravel/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#33 /home/vagrant/Code/leadwise-laravel/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#34 /home/vagrant/Code/leadwise-laravel/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse->handle(Object(Illuminate\Http\Request), Object(Closure))
#35 /home/vagrant/Code/leadwise-laravel/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#36 /home/vagrant/Code/leadwise-laravel/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(59): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#37 /home/vagrant/Code/leadwise-laravel/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): Illuminate\Cookie\Middleware\EncryptCookies->handle(Object(Illuminate\Http\Request), Object(Closure))
#38 /home/vagrant/Code/leadwise-laravel/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#39 /home/vagrant/Code/leadwise-laravel/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(102): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#40 /home/vagrant/Code/leadwise-laravel/vendor/laravel/framework/src/Illuminate/Routing/Router.php(576): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#41 /home/vagrant/Code/leadwise-laravel/vendor/laravel/framework/src/Illuminate/Routing/Router.php(535): Illuminate\Routing\Router->runRouteWithinStack(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request))
#42 /home/vagrant/Code/leadwise-laravel/vendor/laravel/framework/src/Illuminate/Routing/Router.php(513): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#43 /home/vagrant/Code/leadwise-laravel/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(174): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#44 /home/vagrant/Code/leadwise-laravel/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(30): Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}(Object(Illuminate\Http\Request))
#45 /home/vagrant/Code/leadwise-laravel/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(46): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#46 /home/vagrant/Code/leadwise-laravel/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle(Object(Illuminate\Http\Request), Object(Closure))
#47 /home/vagrant/Code/leadwise-laravel/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#48 /home/vagrant/Code/leadwise-laravel/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(102): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#49 /home/vagrant/Code/leadwise-laravel/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(149): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#50 /home/vagrant/Code/leadwise-laravel/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(116): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))
#51 /home/vagrant/Code/leadwise-laravel/public/index.php(53): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))

Spark uses DB::statement at Interactions/Auth/Register.php

public function handle(RegisterRequest $request)
{
    return DB::transaction(function () use ($request) {
        return $this->subscribe($request, $this->createUser($request));
    });
}

/**
 * Subscribe the given user to a subscription plan.
 *
 * @param  RegisterRequest  $request
 * @param  \Illuminate\Contracts\Auth\Authenticatable  $user
 * @return \Illuminate\Contracts\Auth\Authenticatable
 */
protected function subscribe($request, $user)
{
    if (! $request->hasPaidPlan()) {
        return $user;
    }

    if ($request->plan() instanceof TeamPlan) {
        Spark::interact(SubscribeTeam::class, [
            self::$team, $request->plan(), true, $request->all()
        ]);
    } else {
        Spark::interact(Subscribe::class, [
            $user, $request->plan(), true, $request->all()
        ]);
    }

    return $user;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant