jrock2004
2 years ago
240
21
Laravel

AppServiceProvider giving me non-object

Posted 2 years ago by jrock2004

I am trying to add a variable to the AppServiceProvider to pass to the view and I am getting the error of Trying to get property of non-object.

public function boot()
{
    view()->composer('shared.nav', function($view)
    {
        $view->with('isUserRegEnabled', config('app.ALLOW_REGISTRATION', false));
    });
}

If I var_dump the config here, its return me a boolean of FALSE. Not sure what I am doing wrong

Here is how I am using it in my layout file

@if (Auth::guest() && $isUserRegEnabled == true)
    ....
@endif

Maybe I cannot do it this way?

Here is the first full stack:

in 087bb77ee1021a12882b9d85d430c19f0d6eafd5.php line 49
at HandleExceptions->handleError('8', 'Trying to get property of non-object', '/home/jcostanzo/Development/AndroidAppAddicts/storage/framework/views/087bb77ee1021a12882b9d85d430c19f0d6eafd5.php', '49', array('__path' => '/home/jcostanzo/Development/AndroidAppAddicts/storage/framework/views/087bb77ee1021a12882b9d85d430c19f0d6eafd5.php', '__data' => array('__env' => object(Factory), 'app' => object(Application), 'errors' => object(ViewErrorBag), 'obLevel' => '2', 'apps' => object(LengthAwarePaginator), 'isUserRegEnabled' => false), 'obLevel' => '3', '__env' => object(Factory), 'app' => object(Application), 'errors' => object(ViewErrorBag), 'apps' => object(LengthAwarePaginator), 'isUserRegEnabled' => false)) in 087bb77ee1021a12882b9d85d430c19f0d6eafd5.php line 49
at include('/home/jcostanzo/Development/AndroidAppAddicts/storage/framework/views/087bb77ee1021a12882b9d85d430c19f0d6eafd5.php') in PhpEngine.php line 42
at PhpEngine->evaluatePath('/home/jcostanzo/Development/AndroidAppAddicts/storage/framework/views/087bb77ee1021a12882b9d85d430c19f0d6eafd5.php', array('__env' => object(Factory), 'app' => object(Application), 'errors' => object(ViewErrorBag), 'obLevel' => '2', 'apps' => object(LengthAwarePaginator), 'isUserRegEnabled' => false)) in CompilerEngine.php line 59
at CompilerEngine->get('/home/jcostanzo/Development/AndroidAppAddicts/resources/views/shared/nav.blade.php', array('__env' => object(Factory), 'app' => object(Application), 'errors' => object(ViewErrorBag), 'obLevel' => '2', 'apps' => object(LengthAwarePaginator), 'isUserRegEnabled' => false)) in View.php line 149
at View->getContents() in View.php line 120
at View->renderContents() in View.php line 85
at View->render() in fd73ddc8e6fd1fc6ec92a3b3875846744ac5c201.php line 25
at include('/home/jcostanzo/Development/AndroidAppAddicts/storage/framework/views/fd73ddc8e6fd1fc6ec92a3b3875846744ac5c201.php') in PhpEngine.php line 42
at PhpEngine->evaluatePath('/home/jcostanzo/Development/AndroidAppAddicts/storage/framework/views/fd73ddc8e6fd1fc6ec92a3b3875846744ac5c201.php', array('__env' => object(Factory), 'app' => object(Application), 'errors' => object(ViewErrorBag), 'obLevel' => '1', 'apps' => object(LengthAwarePaginator))) in CompilerEngine.php line 59
at CompilerEngine->get('/home/jcostanzo/Development/AndroidAppAddicts/resources/views/layouts/app.blade.php', array('__env' => object(Factory), 'app' => object(Application), 'errors' => object(ViewErrorBag), 'obLevel' => '1', 'apps' => object(LengthAwarePaginator))) in View.php line 149
at View->getContents() in View.php line 120
at View->renderContents() in View.php line 85
at View->render() in 4bcc2a028f6aa437625c3351c8d8fe3307f89f04.php line 15
at include('/home/jcostanzo/Development/AndroidAppAddicts/storage/framework/views/4bcc2a028f6aa437625c3351c8d8fe3307f89f04.php') in PhpEngine.php line 42
at PhpEngine->evaluatePath('/home/jcostanzo/Development/AndroidAppAddicts/storage/framework/views/4bcc2a028f6aa437625c3351c8d8fe3307f89f04.php', array('__env' => object(Factory), 'app' => object(Application), 'errors' => object(ViewErrorBag), 'apps' => object(LengthAwarePaginator))) in CompilerEngine.php line 59
at CompilerEngine->get('/home/jcostanzo/Development/AndroidAppAddicts/resources/views/home/index.blade.php', array('__env' => object(Factory), 'app' => object(Application), 'errors' => object(ViewErrorBag), 'apps' => object(LengthAwarePaginator))) in View.php line 149
at View->getContents() in View.php line 120
at View->renderContents() in View.php line 85
at View->render() in Response.php line 45
at Response->setContent(object(View)) in Response.php line 201
at Response->__construct(object(View)) in Router.php line 1028
at Router->prepareResponse(object(Request), object(View)) in Router.php line 653
at Router->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in SubstituteBindings.php line 41
at SubstituteBindings->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in VerifyCsrfToken.php line 65
at VerifyCsrfToken->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in ShareErrorsFromSession.php line 49
at ShareErrorsFromSession->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in StartSession.php line 64
at StartSession->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in EncryptCookies.php line 59
at EncryptCookies->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 104
at Pipeline->then(object(Closure)) in Router.php line 655
at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 629
at Router->dispatchToRoute(object(Request)) in Router.php line 607
at Router->dispatch(object(Request)) in Kernel.php line 268
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 46
at CheckForMaintenanceMode->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 104
at Pipeline->then(object(Closure)) in Kernel.php line 150
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 117
at Kernel->handle(object(Request)) in index.php line 53
at require_once('/home/jcostanzo/Development/AndroidAppAddicts/public/index.php') in server.php line 21

Screenshot of the code

http://imgur.com/a/bwyc2

Please sign in or create an account to participate in this conversation.