I will try to be as descriptive as possible, as I haven't seen this specific problem anywhere on the Internet.
I have been unsuccessful in getting routing to work on this server without use of the public folder. Only /public/index.php is capable of displaying any sort of content, and it has been static for me.
On the tutorial I was going through (http://scotch.io/tutorials/simple-laravel-crud-with-resource-controllers) he was easily able to use his code to get variables to display. When I look at my live site, I end up with static data that looks like this:
{{ $value->id }} {{ $value->name }} {{ $value->email }} {{ $value->nerd_level }}
All of my files are the exact same as his. My app/config/database.php also has proper credentials.
Apple Server 10.9.4; PHP 5.4.24; Laravel 4.2.8; mysql 5.6.20;
Related
for some views, I have twig that bugs,
some variables are displayed with two braces before
like this one in my code {{ version }}
displays on the interface {{ 1.0
I'm using symfony 5.4 which runs on PHP7.4
does anyone have an idea of how to fix it?
Thanks
this happens only for a few variables
I just want to display a text in a variable like this {{ myvar }}
know that myvar is 'foo'
In the browser it in the browser it returns me {{foo
I have defined a Twig function like this:
new Twig_SimpleFunction('link', 'html_link', ['is_safe' => ['html']]);
so every {{ link(...) }} isn't auto-escaped by Twig. That works.
But html_link() returns a Link object that can be tweaked in the template, to add a URL #fragment or link [attribute]:
{{ link('url', 'label').withFragment('foo') }}
{{ link('url', 'label').withClass('special') }}
But Twig detects that it's not a pure link() anymore, so it's not html-safe anymore, and I have to add |raw to make it work:
{{ link('url', 'label').withFragment('foo')|raw }}
{{ link('url', 'label').withClass('special')|raw }}
Which works. But. Not very pretty.
Can I tell Twig that link().withFragment() and link().withClass() are still html-safe?
Custom filters have an option preserves_safety that kinda works kinda like that:
{{ someFunction(someVar)|someFilter }}
If someFunfction is html-safe, and someFilter was defined with preserves_safety, the output is still safe. I don't want to make filters for ever Link method, so that's not quite good enough.
I can't use Twig_Markup, because:
It has to remain an object as long as possible (withFragment, withClass etc return $this), so you can do multiple things to it, e.g. add a class AND a fragment.
It must be usable outside of Twig. E-mails and flash messages can include links. Only Twig knows (and should know) what a Twig_Markup is. Since it's not an interface, I can't add it to the Link class.
I have this weird problem with my Laravel 5.5 version... I created the auth views using
php artisan make:auth
This command created the views controllers and everything I need to lets get stared to work. But I'm having this visualization problem
As you can see on the register view I have this problem.
The real thing is that "{{ any_command }}" is printing the code that its supose to generate instead of interprating like part of the code. But if I use {!! any_command !!} instead it seems to work propertly. What can happend to my laravel is screwed up. It has nothing to be with the artisan auth method, because I tried to create a new form (using laravel collective form helper) and get the same result.
{{ }} will escape all data before printing. So, if you write any HTML tag inside, it will be escaped and printed as is. Just like your example.
{!! !!} will print unescaped data. This will print the tags correctly, but you have to take care where you use it, because someone could inject unwanted data there.
So, in your case, you should use {!! !!}.
Please, refer to this question: What is the difference between {{ }} and {!! !!} in laravel blade files?
I am not sure where to look / what to look for as I am new to HTML / CSS and Laravel / PHP.
I have a function that is returning a collection (of just one item in this case, but I wanted to keep in the count it uses for use later), and I access the object I want in my view as such:
Top Vulnerability: #foreach ($tvuln as $object)
{{ $object->cve }}
#endforeach
I want to turn the CVE that is returning into a link and have that link, when pressed take me to another page that runs a query to pull up a list of all hosts with the given CVE.
I am trying to wrap my head around how to do this and could use some guidance in terms of what to search for or how to implement this with Laravel / Eloquent.
You could try something like:
#foreach ($tvuln as $object)
<a href="{{ route(routename..., parameters...) }}">
{{ $object->cve }}
</a>
#endforeach
For some more info about routes check here.
In my Laravel application, when I am trying to link the username of the person who has posted in the website with his profile page, with the code:
<div class="media-body">#{{ post.user.name }}
It is giving the error:
Sorry, the page you are looking for could not be found.
1/1 NotFoundHttpException in RouteCollection.php line 161:
But, when I am trying to print #{{ post.user.profileUrl }} it is giving the right address, also in the json response, it is giving the right address, and going to the address is also reaching the specific location.
So, I don’t think it is some problem with post.user.profileUrl, as it seems to work fine, it seems to be some problem with using it with href, the address of the error in Google Chrome is:
http://localhost:8000/%7B%7B%20post.user.profileUrl%20%7D%7D
and the address should have been
http://localhost:8000/users/2 where 2 refers to the id of the user, which I am passing to the user through Vue.js
The problem is #{{ post.user.profileUrl }} is not parsing. %7B%7B%20post.user.profileUrl%20%7D%7D is ASCII representation of {{ post.user.profileUrl }}
Check if the code is in .blade.php file. If it is, you should look into JS template engine if you're using any.
https://laravel.com/docs/5.3/blade#blade-and-javascript-frameworks
The # symbol will be removed by Blade; however, {{ name }} expression will remain untouched by the Blade engine, allowing it to instead be rendered by your JavaScript framework
I think you have a $post model in your view. When you setup relationships between the model Post and User you can link to them through the following:
#{{ $post->user->name }}
This will turn the users profileUrl into a valid link. But therefor you had to setup relationships in the Models.
Post model:
public function user() {
return $this->hasMany('App\Users', 'id', 'user_id');
//first parameter is the Model class
//send is the id of the user table
//thirth is the user_id in the post table
}
And in the User model:
public function posts() {
return $this->hasMany('App\Posts', 'user_id', 'id');
}
Hope this works!
Try this... this should definitely work for you
#verbatim
<div class="media-body">
<a href="{{ post.user.profileUrl }}">
{{ post.user.name }}
</a>
</div>
#endverbatim
I got my problem, the issue is with the javascript library, I am using, known as vue.js, it used to allow usage inside quotes, but in vue 2, they don't, so there is a turnaround for this,
<a :href="post.user.profileUrl">#{{ post.user.name }}</a>
and this works fine.
Thanks to all the people who contributed by answering...