I'm trying to get the current survey id to show within my QR code, however it's only displaying
$survey->id
I'm sure there is something simple I'm missing (first laravel project). Any help would be appreciated.
Reference simple software QR
View
<img src="data:image/png;base64, {!! base64_encode(QrCode::format('png')->size(200)->generate('localhost:8000/survey/view/$survey->id')) !!} ">
Currently you are echoing $survey->id as a string, you want to use the value of said variable.
To do this you will need to remove it from the string and instead place it as the variable inside your url.
<img src="data:image/png;base64, {!! base64_encode(QrCode::format('png')->size(200)->generate('localhost:8000/survey/view/'.$survey->id)) !!} ">
Furthermore you might want to change the way your generate your link and instead use route names or the actions instead of the hardcoded local host, this might give trouble when deploying your application.
Related
{!! Menu::render('admin-sidebar-menu', 'adminltecustom'); !!}
I am editing a laravel code and want to make canges in my sidebar. but i donot understand this line, and I cannot find the source of sidebar.
Anyone who can help me out what does it actually means. and how can I edit my sidebar of the project.
The blade Syntax {!! !!}
is used to used to print HTML as it is without escaping it.
Use it cautiously as it is used to avoid escaping data, and can be result in security failures if used incorrectly.
#Asking
Help me for my problem, when i built a website with Laravel
i am render my post with syntax like this :
<div>
<p>{!! $post->content !!}</p>
</div>
but i have problem, when i insert a i frame inside post, because the html has been removed with {!! !!}.
i have to try use {{ $post->content }}, but all content rendered with HTML
Any solution to this problem? ?
Thanks very much
With {!! you paste content "as is", in other words you become vulnerable to all types of issues like allowing <script> tags to be placed into your templates.
The {{ syntax will escape any HTML thus what you see is the actual html characters without actually parsing it (i.e. doing {{ '<b>bold</b>' }} will not result in a bold font but in the text <b>bold</b>).
Now with your problem: there are some cumbersome ways to filter out any html tags yourself and leave the <iframe>'s in there (something like {!! only_iframe($content) !!}), but it is quite difficult and will likely not result in a safe solution.
Your own answer which stated that you used {!!html_entity_decode($post->content)!!} simply means that your HTML was encoded to start with, which is not something I can deduct from your question. Note that you are now vulnerable to malicious code injection if you are not certain you can control the contents of $post->content.
I'm trying to break a line but it's always displayed whatever I do so I guess I'm doing something wrong.
Here is my line from my php file
But it's displayed like this :
My site is designed to help content creators on the web, create a free account and start \nmaking money now.
Can you help me please ?
Replace \n with <br>
Use <p></p>
My site is designed to help content creators on the web, create a free account and start making money now
Use CSS white-space property for \n (example)
try to use <br> on blade, and if you use {!! !!} i think that must be inner html inside your string. cmiiw
You can save your html text as variable like this
$subtitle_welcome = "<p>My site is designed to help content creators on the web, create a free account and start </p> <p> making money now.</p>";
OR
$subtitle_welcome = "My site is designed to help content creators on the web, create a free account and start <br/> making money now.";
And you have to show in blade
{!! $subtitle_welcome !!}
I have laravel template.blade.php
<div class="classone">
<div class="classtwo">
text
</div>
<div class="classtwo">
text
</div>
</div>
And I would like to display the code to the user as it is. Incluing new line and indents.
I was playing around with {!! !!}, nl2br(view()->render() even Blade::compileString but was unable to find an elegant solution. Everytime I was able to make it work it was difficult to maintain and every small change to the displayed code was laber intense.
I would like to ask for a suggeston how to display more complex html/css/js code to user. I though it will be fairy often topic but was unable to find anything which would help me.
Thank you in advance.
I tried some things out. They may seem a little bit 'hacky' but I think they will suit your purpose. I used a freshly created Laravel 8 application as an example.
<pre>{{ file_get_contents( resource_path('views/welcome.blade.php')) }}</pre>
You can use the Blade facade to compile your blade file to plain php if you want:
<pre>{{ Blade::compileString(file_get_contents( resource_path('views/app.blade.php'))) }}</pre>
I put <pre></pre> tags around the output to show line breaks. It makes the code more readable.
When I am storing something using ekeditor in my Laravel project, I got the data in view the data with a <p> tag. How can I store my data without a <p> tag
Result:
<p>good<\p>
Expected result:
good
use textarea instead of CKEditor if you don't want tags to be stored.
otherwise, you can try this.
if you use {{ $data->xyz }} , it will show texts with tags. So use {!! $data->xyz !!} , it won't show tags but will convert in html codes.