reinink / client-side-rendering-in-laravel

199 stars 36 forks source link

Added ability to pass authenticated user. #11

Closed Juhlinus closed 5 years ago

sixlive commented 5 years ago

I was playing around with this and this seems to work well.

ViewFactory::macro('component', function ($name, $data = []) {
    return View::make(
        'app',
        [
            'name' => $name,
            'data' => array_merge($data, [
                'user' => auth()->user()
            ]),
        ]
    );
});
<script>
    export default {
        props: ['podcasts', 'user'],
        mounted() {
            console.dir(this.$props)
        }
    }
</script>