Php / laravel&#34; link_to_route&#34;到JQuery <a> tag

时间:2017-05-03 19:13:00

标签: php jquery laravel-4

I have this in Laravel

  {{ link_to_route('users.publications.create', 'text of link', ['users' => $user->username]) }}

What it does is create a "< a >" HTML tag to a view in the site link this:

<a href="http://kinbu.co/users/luis02lopez/publications/create >text of link</a>

I want to have the same result in JQuery but it uses the "users" in the link route as other user:

            var action_call = $({{ link_to_route('users.publications.create', 'publica uno como intercambio',
            ['users' => $user->username], ['style' => 'color:blueviolet']) }}
            });
            body.append(action_call);

With which I have the next error: http://imgur.com/a/Lrmbg

我是否需要使用用户名创建其他var

如果有任何想法会有很大的帮助。感谢

1 个答案:

答案 0 :(得分:0)

获取已记录(和主要)用户信息的解决方案是:

Auth::user()->username

这会带来登录用户的数据。