Using both Laravel blade and vue variables together - laravel

I am trying to use both vue and blade variables to make calculation as follow :
#{{vueNumber}} * {{$bladeNumber}}
and I would want to get result of multiplying these 2 numbers.
I have tried using vue variable inside #php and it threw error , how can this be achievable ?

Related

Vue varibale inside Laravel helper

This is my Laravel route:
Route::get('/article/{id}', 'ArticleController#show')->name('article');
This is my blade in Laravel:
Article
I tried this:
How to place vue variable inside a laravel bracket
But for me this return:
https://example.xyz/article/%7B%7B%20value.id%20%7D%7D
I need something like that:
Article
Where article.id is a Vue variable.
How can I do this?
You can't do it this way. But you can use Ziggy which allows you to use route() function in vue like you are using it in laravel.
https://github.com/tightenco/ziggy
Then in your vue component you can call route('article', {id: article.id})
You can try this
Article

How to pass data from Vue component to Laravel route or controller

I'm using Laravel with a Vue component called vue-good-table. I just want to pass an array from my component to one of my Laravel routes and consequently to the respective controller.
I tried with axios but in this case it doesn't work, because the controller that receives the data must return straight away a Laravel view (but using axios the view is returned to the Vue component method as a response).
Maybe I can try to use a button that calls the route but I'm having trouble passing the array I need to pass. The route I specified must use the GET method.
MyTable.vue
<a :href="/pdf-download-selected/">
<button>Download PDF</button>
</a>
I really don't understand if my approach to Laravel with Vue is completely wrong or what..I mean I know how to pass data from Laravel to Vue, but not the opposite.
What do you recommend I do?
Thanks!

Shorten directive in laravel

I'm trying to use laravel component and slot.
As I'm using blade templates under components folder, my blade syntax is something like this
#component('components.button',['data'=>$data])
#endcomponent
Here, every times I call it, I have to write the word "component" multiple times.
can I shorten it as below?
#component('button',['data'=>$data])
If yes, how can I achieve it?
You must use of Aliasing Components functionality
If your Blade components are stored in a sub-directory, you may wish to alias them for easier access. For example, imagine a Blade component that is stored at resources/views/components/alert.blade.php. You may use the component method to alias the component from components.alert to alert. Typically, this should be done in the boot method of your AppServiceProvider:
Blade::component('components.alert', 'alert');
Referense

Use a variable inside a variable in Smarty 2 template

I am trying to use a smarty variable inside a smarty variable in a template.
The following will work in smarty 3 but not in smarty 2:
{$_content_{$id}.content_title}
to display for example:
{$_content_10.content_title}
In smarty 2 it only throws an error. Is there any way to do this in smarty 2?

Laravel 4.1 Blade + Handlerbar escaping issue (%20, %7B etc ..)

I'm working with Laravel 4.1 (recently update to) and Handlebars.
I have a view where I mix Blade template and Handlebars template.
My problem is that this line:
View
return me this :
http://local/event/%7B%7Bid%7D%7D
instate of :
http://local/event/7 (if id = 7)
Note that this line return the correct value :
<span>#{{id}}</span>
The issue occurs only in the url() Laravel helper :(
Thank you in advance!
You cant get Handlebars to put the $id there - because it is a Laravel PHP function url() that must resolve first, and the result is passed to Handlebars.
i.e. this would work:
View
But you cant get Handlebars to use an ID in the Laravel function.
What you are trying to do in your example is get Laravel to pass a URL to Handlebars, Handlebars inserts the ID, then Laravel finishes the function - which wont work.
In my case the workaround is
View

Resources