How to access url parameters on View::composer


username

I want to receive url parameter in method View::composerbut I don't know how to do it...

This is in filters.php:

View::composer('profile.followers', function($view){
    dd($view->parameters);
    $view->with('menus', $menus);
});

Here is my route:

Route::get('/outfit/{id}/{slug}', [
    'uses'      => 'PictController@view',
    'as'        => 'pict.view',
    'before'    => 'assets'
]);

Here is my controller:

public function followers($username){
   $d['d'] = Follow::with('followers')->where('id_user_to', 10)->get();
   $this->layout->nest('content', 'profile.followers', $d);
}
JofryHS

Check out the Laravel API documentation on Router , which you can use to return an instance.Route::current()Route

Then according to the Route documentation you can use parameters().

E.g:

$currentRoute = Route::current();
$params = $currentRoute->parameters();

dd($params); // Will dump the keys and values of current route parameters

UPDATE Note that this only works on 4.1+, before that the method names were different.

// 4.1+
Route::current();
Route::parameters();

// Before 4.1
Route::getCurrentRoute();
Route::getParameters();

Related


How to access url parameters on View::composer

user3207586 I want to receive the url parameters in the method View::composer but I don't know how to do it... This is in filters.php: View::composer('profile.followers', function($view){ dd($view->parameters); $view->with('menus', $menus); }); This i

How to access url parameters on View::composer

username I want to receive url parameter in method View::composerbut I don't know how to do it... This is in filters.php: View::composer('profile.followers', function($view){ dd($view->parameters); $view->with('menus', $menus); }); Here is my route: R

How to access url parameters on View::composer

username I want to receive url parameter in method View::composerbut I don't know how to do it... This is in filters.php: View::composer('profile.followers', function($view){ dd($view->parameters); $view->with('menus', $menus); }); Here is my route: R

How to access parameters of URL in iframe?

Javier Munoz I have the following HTML with jQuery code: <div id="info" style="width: 100%; height: 280px; overflow-y: scroll;"></div> var url1 = cbcWMS1.getGetFeatureInfoUrl (evt.coordinate, viewResolution, 'EPSG:3857', {'INFO_FORMAT': 'text/html'}); $('#in

How to access URL parameters in useEffect?

Beulah Akindele I have a functional component trying to access a URL parameter already named in react-router via a hook. useEffect(() => { document.title = props.match.params.subject UserServices.getSubject(props.match.params.subject) .then(resp

How to access URL parameters in useEffect?

Beulah Akindele I have a functional component trying to access a URL parameter already named in react-router via a hook. useEffect(() => { document.title = props.match.params.subject UserServices.getSubject(props.match.params.subject) .then(resp

How to access parameters of URL in iframe?

Javier Munoz I have the following HTML with jQuery code: <div id="info" style="width: 100%; height: 280px; overflow-y: scroll;"></div> var url1 = cbcWMS1.getGetFeatureInfoUrl (evt.coordinate, viewResolution, 'EPSG:3857', {'INFO_FORMAT': 'text/html'}); $('#in

How to access URL parameters in useEffect?

Beulah Akindele I have a functional component trying to access a URL parameter already named in react-router via a hook. useEffect(() => { document.title = props.match.params.subject UserServices.getSubject(props.match.params.subject) .then(resp

How to access URL parameters in useEffect?

Beulah Akindele I have a functional component trying to access a URL parameter already named in react-router via a hook. useEffect(() => { document.title = props.match.params.subject UserServices.getSubject(props.match.params.subject) .then(resp

How to access URL parameters in useEffect?

Beulah Akindele I have a functional component trying to access a URL parameter already named in react-router via a hook. useEffect(() => { document.title = props.match.params.subject UserServices.getSubject(props.match.params.subject) .then(resp

How to access route parameters outside view

Roberto Bonvallet I'm writing a very simple Angular application that displays information about football tournaments. For each tournament in the database, I want to display a view of the match or stats, so I'm implementing the following simple URL scheme: foo/

How to access URL parameters from BasePermission?

kale I'm trying to write custom rest_framework permissions to prevent users from querying information that is not in the same company as them. Unfortunately, I can't seem to access any URL parameters from has_permission()or has_object_permissions(). Here is th

How to access parameters from URL in cakephp 3

Anuj TBE In the cookbook for cakephp 3. Given the following command to build the URL echo $this->Url->build([ "controller" => "Posts", "action" => "view", "foo" => "bar" ]); will output as /posts/view/foo:bar How to access foo:barin action and sa

How to access URL parameters from BasePermission?

kale I'm trying to write custom rest_framework permissions to prevent users from querying information that is not in the same company as them. Unfortunately, I can't seem to access any URL parameters from has_permission()or has_object_permissions(). Here is th

How to access URL parameters in Meteor helper functions?

Noamyoungerm For some pages in my application, I want to enable printable mode, where some elements of the page are hidden when URL parameters are included ?print=true. For now, I've tried a workaround that involves sending the URL parameters as a data context

How to access URL parameters from BasePermission?

kale I'm trying to write custom rest_framework permissions to prevent users from querying information that is not in the same company as them. Unfortunately, I can't seem to access any URL parameters from has_permission()or has_object_permissions(). Here is th

How to access Java enums as URL parameters in thyme?

Karsten I want to access Java enums in thymeleaf. I think it will work like this <a th:href="@{/(somekey=T(com.example.Myenum.FOO.getBaz()))}">my link</a> Unfortunately, that's not the case. I searched a lot of examples but couldn't find a solution, do you ha

How to access URL parameters in Meteor helper functions?

Noamyoungerm For some pages in my application, I want to enable printable mode, where some elements of the page are hidden when URL parameters are included ?print=true. For now, I've tried a workaround that involves sending the URL parameters as a data context

How to access Java enums as URL parameters in thyme?

Karsten I want to access Java enums in thymeleaf. I think it will work like this <a th:href="@{/(somekey=T(com.example.Myenum.FOO.getBaz()))}">my link</a> Unfortunately, that's not the case. I searched a lot of examples but couldn't find a solution, do you ha

How to access URL path in Django view

Solab How to access URL in Django view. I have view handling for the following 5 urls: localhost:8000/standings/ localhost:8000/standings/q1 localhost:8000/standings/q2 localhost:8000/standings/q3 localhost:8000/standings/q4 my opinion is class StandingsView(

How to access URL path in Django view

Solab How to access URL in Django view. I have view handling for the following 5 urls: localhost:8000/standings/ localhost:8000/standings/q1 localhost:8000/standings/q2 localhost:8000/standings/q3 localhost:8000/standings/q4 my opinion is class StandingsView(

How to access URL path in Django view

Solab How to access URL in Django view. I have view handling for the following 5 urls: localhost:8000/standings/ localhost:8000/standings/q1 localhost:8000/standings/q2 localhost:8000/standings/q3 localhost:8000/standings/q4 my opinion is class StandingsView(

How to access URL path in Django view

Solab How to access URL in Django view. I have view handling for the following 5 urls: localhost:8000/standings/ localhost:8000/standings/q1 localhost:8000/standings/q2 localhost:8000/standings/q3 localhost:8000/standings/q4 my opinion is class StandingsView(

Django, view url parameters

Alex I have a companymodel and each instance of it has a foreign key named for the adminuser . I'm writing a view to allow company admins to manage their company: urls.py: path('admin/crn=<company_spec_url>', CompanyAdminView.as_view(), name="CompanyAdminView"

Access URL parameters in XSL

username I want to get the URL parameter from the URL of the current page in XSL and use it to test the condition in the template xpath. E.g: <xsl:apply-templates select="//search-results/orders/order[@id = URL Parameter]" mode="tableContent"/> I have no con

Access parameters from URL

George Patterson I am very new to Rails and ruby code. I have passed many parameters to the URL from link_to. However, when I try to access the parameter in _form.html.erb, I don't get any errors, but it doesn't output the parameter. Any help would be greatly

Access parameters from URL

George Patterson I am very new to Rails and ruby code. I have passed many parameters to the URL from link_to. However, when I try to access the parameter in _form.html.erb, I don't get any errors, but it doesn't output the parameter. Any help would be greatly

Access parameters from URL

George Patterson I am very new to Rails and ruby code. I have passed many parameters to the URL from link_to. However, when I try to access the parameter in _form.html.erb, I don't get any errors, but it doesn't output the parameter. Any help would be greatly

Access URL parameters in XSL

username I want to get the URL parameter from the URL of the current page in XSL and use it to test the condition in the template xpath. E.g: <xsl:apply-templates select="//search-results/orders/order[@id = URL Parameter]" mode="tableContent"/> I have no con