I want to send static value through my url from my blade file .But this not working.can you give me the solution
>
> This is link
you have syntax error you can fix by
This is link
here ?rfq=1 this will come under '' this tag as it is string
as your router is defined as this
Route::get('/user-login/{email}/{password}', 'UserController#user_login')->name('users.user_login');
you should use route name and pass the data like this
This is link
then if you need to pass you can use like this
This is link
this will generate url like localhost:8000/user-login/example#mail.com/1234?rfq=1"
ref link https://laravel.com/docs/8.x/helpers#method-route
If you are using {} in your route(route parameter method) then no need to have '?' in your URL. If you need 127.0.0.1:8000/user-login?rfq=1 as your URL then create route without route parameters as
Route::get('/user-login,'UserController#user_login')->name('users.user_login');
Related
How can we pass file path to route like this,
<a href={{route('route.name',['path'=>'uploads/xyx/'.$id.'/'.$attachment_name])}}>download</a>
However, I would like this to hit
Route::get('download/{path},'Controller')->name('route.name')
When I hit this route my url got transformed somehow like this -> download/uploads/44/filename which is causing not found exception!
I want to pass the path as a parameter, where slashes should have to be ignored! so that I can get full path in my controller!
As per the documentation you can do this:
"The Laravel routing component allows all characters except /. You must explicitly allow / to be part of your placeholder using a where condition regular expression"
Route::get('download/{path}', ...)->where('path', '.*');
Laravel 7.x Docs - Routing - Parameters - Encoding Forward Slashes
use get parameter remove {path}
Route::get('download,'Controller')->name('route.name')
in blade
<a href={{route('route.name',['path'=>'uploads/xyx/'.$id.'/'.$attachment_name])}}>download</a>
this will generate url like route.name?path=download/uploads/44/filename
still u will get data in controller like $request->path
I would like to create an url as shown below
/domain/url=cloud_hosting&name=cloud_hosting
this is the href url that I use in my blade
continue
but that href url is generating different route
/domain/cloud_hosting/cloud_hosting
I have tried this one:
Continue
and that's working fine. But is there any other way which is nice and beautifull?
Thank you
you can do something like below. simply make a get request as in Web.php
Route::get('domain')
and can use it like below and can pass multiple query strings:
continue
You can also use the query method:
url('domain', Arr::query(['url' => request()->segment(2), 'name' => $page_name]))
// /domain/url=cloud_hosting&name=cloud_hosting
I use $.getJSON() to retrieve some data for a couple of cascading dropdowns in my form. $.getJSON() automatically appends the parameter at the end of the URL like domain.com/controller/method/?parent=5
So, I've declared my method like public function method($parent) which works file, but the same method will be used from other parts of the website that will call it like domain.com/controller/method/5
I tried to create a route in routes.php like the one below:
$route['business/regions/?parent=(:num)'] = 'business/regions/$1';
but it doesn't seem to work. Am I doing something wrong? Maybe ? is confusing the regex parser of the router? Do I have to escape it somehow to make it a 'literal' ? ?
Or is it that router is not used to 'rewrite' get parameters at all? I'm very confused, as it should work but it doesn't and I'm wondering what's wrong with it...
Codeigniter route parameters are for url parameters. It is particularly useful when trying to create a REST styled url pattern.
What you're trying to do is get url query string from the url which is not supported via the Codeigniter router. For you to get what you want you can do the following:
In your routes.php:
$route['business/regions'] = 'business/regions';
and in your controller Business.php:
public function regions() {
//the numeric id you're looking for
$parent = $this->input->get('parent');
}
I'm trying to retrieve string as parameter using following URL scheme:
www.myapp.com/[String]
Is there any way I can do this?
*Based on my research, Codeigniter doesn't accept string parameters unless I include the Controller's name in URL: www.myapp.com/[Controller Name]/[String]
But this doesn't solve my problem :(
You're right, CI requires controller name at URI, but You can use default_controller.
At config/routes.php add route rule $routes['(:any)'] = 'welcome/index';, remove index.php from Your URL (there're many tutorials and how-to for this), and at last useuriclass at Yourindex()method ofwelcome` controller:
function index(){
var_dump($this->uri->uri_string());
}
I have a template file at ../page/video.phtml and it's served at http://mysite/video.
I want to add params in the url to play different videos on that page. I can add it as a query string param, http://mysite/video?select=filename but I would prefer to use http://mysite/video/filename.
However, when I try this I get a 404. What would I have to do to achieve this?
I'm using Magento 1.7
You must explicitly include all the action parts (route, controller and action) in the URL before adding parameters this way, because when you use http://mysite/video/filename, Magento looks for the index action of the filename controller for the module having a front route named video (which does not exist, hence the 404 error).
From the URL you gave, a working URL would rather look like this : http://mysite/video/index/index/select/filename