Adam Silva
Adam Silva

Reputation: 1047

Laravel Link an Image to a Route

I'm trying to put an image, and link that image to a Route so it can do a series of stuff.

Here is the code I have:

{{ (Request::is('add/{IDDisco}') ? ' class="active"' : '') }}><a href="{{{ URL::to('add/$disco-        >IDDisco) }}}">
                {{ HTML::image('assets/ico/add.ico', 'Add', array('style' =>   'width:20px;height:20px')) }}</a>

I get the error: syntax error, unexpected 'assets' (T_STRING)

<?php echo (Request::is('add/{IDDisco}') ? ' class="active"' : ''); ?>><a href="<?php echo e(URL::to('add/$disco->IDDisco)); ?>">
            <?php echo HTML::image('assets/ico/add.ico', 'Add', array('style' => 'width:20px;height:20px')); ?></a>
            </p>

Anyone knows how to do this? If you want me to put anything else, just say.

Upvotes: 0

Views: 159

Answers (1)

Bogdan
Bogdan

Reputation: 44526

You have a syntax error in the part where you generate link URL. You're missing the ending string quote and you have some extra spacing that should not be there. So instead of this:

<a href="{{{ URL::to('add/$disco-        >IDDisco) }}}">

You should have this (assuming that the variable $disco is an object that has the property IDDisco):

<a href="{{{ URL::to('add/' . $disco->IDDisco) }}}">

Upvotes: 1

Related Questions