简体   繁体   中英

how to put URL inside of laravel blade

I have database structure like Book & download link ..

$book= new Book();
$book->name = $request->Input(['name']);
$book->download_link = $request->Input(['download_link']); // eg. https://bnbooks.com/1234
$book->save();

now if i want to give this in blade page ..like download link..how do i put in href tag so that it will redirect the user to that page?

<a href="{{URL::to($book->download_link)}}">{{$book->name}}</a>
// This doesn't work

URL::to is a function to create a url on your site from only the path (for example /foo/bar ). Since you store the full URL, you can just do

<a href="{{$book->download_link}}">{{$book->name}}</a>

You can do something like

<a href="{{ $book->download_link }}">{{$book->name}}</a>

to show the url.

If you have a url like /example/example and you also want to show the domain name in front of the url, you do

<a href="{{ url($book->download_link) }}">{{$book->name}}</a>

This will create an url like localhost:8000/example/example (In case of localhost)

希望能奏效

<a href="{{ url('/'.$book->download_link) }}">{{$book->name}}</a>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM