mercredi 26 août 2015

Laravel pass object to view

When I'm trying to pass an object through a view with the AppServiceProvider it gives an error an says

Trying to get property of non-object

This is currently my App\Providers:

<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use App\User;
use Auth;
class AppServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        $users = Auth::user();
        view()->share('user','users');
    }

    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        //
    }
}

And when I say in the view:

{!! user->name !!} 

It throws an error.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1NAOa9M
via IFTTT

Aucun commentaire:

Enregistrer un commentaire