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

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

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'];

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

Laravel $request->filled() method throws error

I am trying to check if value is present on the request or not using filled function in laravel ! But Laravel throws BadMethodCallException.
Preview of what I got in response
Is this method deprecated ?? or any similar approach to check if request parameter is empty in laravel ??
There is a filled method on Illuminate\Http\Request in Laravel >= 5.5
Would need to know what version you are using to look into it more.
You can use the has() method as well:
if ($request->has('name')) {
// code here
}

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

Detect if running from middleware in Laravel

Is there a way to detect if my code is running from a Middleware. I have a helper that get's called from everywhere for date conversions. In that helper, I check for route names \Route::current()->getName() or if running from console \App::runningInConsole().
When my middleware calls the helper, I get an error with \Route::current()->getName() since \Route::current() is null
Is there a way of knowing if code executed from my middleware?
Thanks
Problem solved
I had problems integrating Cashier and middleware and got that fixed, and to prevent going to my timezonehelper to set dates, I used the protected $dates = ['trial_ends_at', 'ends_at'];
Thanks for your help
You can get full url in laravel using the code below
$fullUrl = Request::capture()->fullUrl();
And You can get current url in laravel using the code below
$currentUrl = Routes::current()->getName();
In this case, you have to use this namespace given below:
use Illuminate\Support\Facades\Route as Routes;

Resources