Vue varibale inside Laravel helper - laravel

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

Related

How do I get url parameter in Blade template (Laravel v8)

As the title suggests, I am resurrecting an old Laravel project (from v5) and upgrading to v8.
In my blade template I referred to $request->q which would get the q=somevalue part of my url, in laravel 8 however this doesn't work.
I have tried a number of methods found in this SO post but none of them work.
Have you tried request() helper function with one of these
request('q')
request()->get('q')
request()->query('q')
I had this issue too but Still, it will works, when it in this way
Controller
in here this should have use Illuminate\Http\Request;
public function func1(Request $request){
$aid=$request->id;
}
Route
Route::get('/url_name/{id}',[
'as'=>'url_name',
'uses'=>'ControllerName#func1'
]);
Blade
<form id="form_1" action="{{'/url_name',$id)}}" method="POST" enctype="multipart/form-data">
OR
You can try with,
$request['q'];

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!

Using route() and with() in html view in Laravel 5.6

For redirection, in controllers, we can write like this:-
Redirect::Route('front_index')->with('RegError', 'An error occured while adding the user.');
How can I set up the href of an anchor tag so that I can send the 'RegError' too? Say something like this?
<a href="{{route('front_index')->with('RegError', '')}}">
actually you can't because with function is used to pass parameters from controllers to view and route helper doesn't have this method.
You need to make request and in controller pass your RegError

Getting the URL details - Laravel

I am working on a Laravel project, where I want to toggle partials based on the URL data like
foo.bar.com/#itemone/create
foo.bar.com/#itemone/view
Basically, I want to pass whether it is create or view to the partials like this
#include('partials.layouts._core_activity_header',['layout_type' => "create"])
How do I achieve this? Any help would be appreciated.
you can use the route name
Route::getCurrentRoute()->getName()
this will return the route alias

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