Can't use word 'error' in laravel route path? - laravel-5

I have a problem in laravel route study.If I defined a route like this:
Route::get('error/{name}',function($name){
return "Sorry $name. Something is wrong with your account.";
});
Then I access it by localhost/error/john, browser said not found url.But if i change error to other word like 'wrong'.And I can access by `localhost/wrong/john'.So can anyone tell me what is wrong with my code?

Related

Set tab name in redirect to route in laravel

in laravel 8 i will redirect the user to a route after doing the query.
There are many tabs on the page where I want the user to be transferred
I wrote the code like this
(Of course I know it's wrong, but I wanted to try, and yet I did not think of another way
return redirect()->route('admin.auth.user.show', $user . "#edit-information")->withFlashSuccess(__('The user was successfully updated.'));
I get an error with this code
What is your solution?
What you can do to activate for example bootstrap tab based on #web paramater is use the redirect() method like this:
return redirect()->route('backend.settings.show', ['eshop' => $eshop->id, '#homeImages']);
Eshop is regular route parameter but '#homeImages' is added to the end of the route which is then picked up by the js on page load.
In Laravel there is a withFragment method, which add a fragment identifier to the URL.
return redirect()->route('admin.auth.user.show', ['user' => $user])->withFragment('edit-information');
https://laravel.com/api/8.x/Illuminate/Http/RedirectResponse.html#method_withFragment

(CI 4) How to redirect within Controller?

how can I refer to another within one controller? In CI3 (for example in the controller client.php) I solved this as follows:
redirect('/Clients', 'refresh');
but that no longer seems to work in CI4. (Msg: "route cannot be found while reverse-routing.")
I Also tried
redirect()->route('/Clients');
but the error is the same.
redirect()->to('/Clients');
redirects nowhere (no output, nothing)
For a better understanding: I want to use a controller (e.g. Clients/create to Clients/details)
What you should notice is that redirect() does not just set headers like it used to do in CI3. In CI4 it returns a RedirectResponse object with which you can ask your controller to do a redirection.
To do so, you need to return this RedirectResponse object inside your controller. Without the return statement, the redirection won't happen.
An other thing to notice is that redirect() can be called with some "options" :
Going to a named route
return redirect()->route('named_route');
or
return redirect('named_route');
To use this, you need to add a named routes in your app/Config/Routes.php file :
$routes->get('/', 'MyController::index', ['as' => 'named_route']);
Going to a specific URI
return redirect()->to('Clients');
It will redirect you to your base url with /Clients at the end.
Please check out the doc for further informations : https://codeigniter.com/user_guide/general/common_functions.html#redirect
#ViLar gives the correct answer, but it's important to note that when using auto routing the CI3 version redirect('home'); becomes return redirect()->to('home');
It's confusing to just say "Going to a specific URI" and omit that this means auto routed controllers.

404 in Routes.php with laravel 5

I have a route that I have recently change to:
Route::get('/tournaments/{{tournamentId}}/invite/{token}', 'InviteController#register');
When I try to access it with
http://laravel.dev:8000/tournaments/1/invite/ad5a5sd
I get a 404...
All my others routes work fine...
Any idea what could be the problem??
It's a small error (easy to overlook), but you shouldn't be using double curly braces. {{tournamentId}} should be {tournamentId} so the route should be:
Route::get('/tournaments/{tournamentId}/invite/{token}', 'InviteController#register');

Laravel 4 - Duplicate Url

I am having a problem with the confide package for user authentification.
My problem is that when I login, I am redirected to the login page which throws an notFoundHttpException because the url I am redirected to is duplicated... looks like this:
http://www.mypage.dev/http://www.mypage.dev
My virtual host is set up like this here
https://github.com/daylerees/laravel-website-configs/blob/master/apache.conf
What is making this happen?
---EDIT---
Gathering more experience...
It seems that this occurs when the following redirect is used:
return Redirect::action('Controller#action')
If I use:
return Redirect::to('/action')
everything is just fine.
My route look like this:
Route::get('/action', 'Controller#action');
Change your Route to
Route::get('action', 'Controller#action');
Your current route's definition appends /action to the end of the current URL.
Because of the underscore, the url http://newsletters_app.dev is invalid according to filter_var($url, FILTER_VALIDATE_URL). Because of this, HTML::link() is generating a duplicate base. Solution is to simply remove the underscore from the URL.

Can't use Get in CodeIgniter

So I'm using codeigniter and I've had very letter experience with it so far but here's my issue.
I have an if statement I've set up that says if (#$_GET['f'] == 'callback') then do something, if not, do something else.
So basically my URL ends up looking like this:
http://localhost/finalproject/myspacedev/index?f=start
and all I get is a 404 page. I've tried turning on get in the config, done a bunch of reading on here about using the uri segment class in CI, but all I get are 404 errors. What am I doing wrong here? It's driving me nuts!
Nevermind I'm dumb.
It's PATH_INFO, not PATH INFO.
Still having some issues but for now I'm good.
CodeIgniter automatically maps $_GET variables to class member parameters, which is far nicer to work with (see Controllers in the CI docs).
An example:
<?php
class blog extends Controller {
function archives($filter = '') {
// $filter is a $_GET paramemter
}
}
?>
The above controller would be available at /blog/archives/ and anything after that portion of the URI would be passed as the $_GET parameters. If /blog/archives/ returns a 404, then you probably don't have the .htaccess file in the web root, or you may not have it enabled in the Apache configuration.
It must have something to do with my .htaccess file, even though I thought I had it set up correctly. I tried to do it that way and never had any success so I just ended up enabling GET with the parse_str line that everyone passes around.
In any case, I got it to work even if its not the cleanest, most efficient way.

Resources