My setup
I set in app URL in .env:
APP_URL=http://local.task-app.com
I have one route:
Route::get('/login/callback',
'LoginController#teamwork')->name('loginCallback');
I get API route with the following:
$callbackUrl = route('loginCallback');
// This returns http://local.task-app.com/login/ as expected.
What I'm trying to do:
I want to update Base App URL
I updated .env
APP_URL=http://local.review-app.com
I reference the $callbackUrl in the same fashion:
$callbackUrl = route('loginCallback');
What's happening:
It's still returning http://local.task-app.com/login/callback. The url is not updating to the most recent .env change.
Related
Here is the problem.
I started a dingo project and am using laravel-modules in it. Every module has its own routing files. Using the project in development environment, everything works fine.
But when I run php artisan config:cache, when a request comes to laravel, it return the response The version given was unknown or has no registered routes. As I see, the problem is dingo just check the default api.php and web.php files to find the route. But module routes are not stored in that files. I store them in Modules/module_name/route/api.php file (as laravel-modules suggested).
Any suggestion would be welcome.
change api file of module with version param in group session like this:
$api = app('Dingo\Api\Routing\Router');
$api->group(['version' => 'v1'], function ($api) {
...
});
I am making a system using the Laravel 5.6
I uploaded to a server that I have and access this externally
You used the software when a route uses resouce, for example::
Route::resource('materiais', 'MaterialController');
Because the routes you create using Route::get, Route::post, Route::patch, etc.., work correctly
For example, if I'm in
http://192.168.0.23/sisobras/public/neworder
and I go to open a new order he goes to the address
http://192.168.0.23/sisobras/public/serviceorder/2/create?
running correctly, a route looks like this:
Route::get('serviceorder/{id}/create', 'ServiceOrderController#create');
but if I'm in
http://192.168.0.23/sisobras/public/materials
and you can register new material the url looks like this:
http://192.168.0.23/materials/create
The view is called on the controller so
public function create()
{
$units = Units::all();
return view('materials/create', compact('units'));
}
and the lack of sisobras/public/ a Not Found error
When used with the php artisan serve works correctly
I have create a Polymer based Dashboard which I want to integrate with my Laravel site. My Dashboard is working fine but I have issues with routing in Polymer.
I want my Dashboard to reside at:
http://example.com/dashboard
I have set up my Laravel route as follows:
Route::get('dashboard',function(){
return View::make('polymer.dashboard');
});
and my dashboard urls should be like:
http://example.com/dashboard/#!/feedbacks
But, I am confused about what setting to make in app.js. Current app.js:
// Sets app default base URL
app.baseUrl = '/';
if (window.location.port === '') { // if production
// Uncomment app.baseURL below and
// set app.baseURL to '/your-pathname/' if running from folder in production
//app.baseUrl = '/dashboard/';
}
Under these settings, when I navigate to http://example.com/dashboard, when Polymer finishes loading, the url changes to http://example.com/.
If you haven't told the router to not use hashbangs then navigating to /dashboard won't work, it's expecting #!. You'll need to go into app/elements/routing.html and remove the line that says hashbangs: true. You'll also need to set the baseUrl to /dashboard/. Your server will also need to always return the index.html for any URL that starts with dashboard. So if the user tries to go to example.com/dashboard/feedback it should send down the index.html page again.
After you've made the change to routing.html, go into the devtools settings and enable Disable cache (with dev tools open). Then reload the app to make sure it isn't serving a cached version of the file.
When I'm sending a queued mail message from a laravel queue the route urls always return localhost instead of the url set in config app.url. The rest of the site works fine but just urls generated from the queue are wrong.
The url in app.php is only used when Laravel runs as a console application. Your URLs where created using the domain name the application runs under: localhost
You can fix this by only generating a relative URL and then prepend the domain name from the config:
$url = Config::get('app.url') . route('route-name', null, false);
(The third argument to route() is $absolute = true. By setting that to false you get a relative URL starting with /)
In a Laravel 4 installation, Using Jeffrey Way's Laravel 4 Generators, I set up a 'tweet' resource, using the scaffolding command from his example:
php artisan generate:scaffold tweet --fields="author:string, body:text"
This generated the model, view, controller, migration and routing information for the tweet type. After migrating the database, visiting http://localhost:8000/tweets works fine, and shows the expected content.
The contents of the routes.php file at this point is:
Route::resource('tweets', 'TweetsController');
Now I would like to move the url for tweets up one level into admin/tweets, so the above url should become: http://localhost:8000/admin/tweets. Please note that I am not treating 'Admin' as a resource, but instead just want to add it for hypothetical organizational purposes.
Changing the routes.php file to:
Route::resource('admin/tweets', 'TweetsController');
Does not work, and displays the following error:
Unable to generate a URL for the named route "tweets.create" as such route does not exist.
Similarly when using the following:
Route::group(array('prefix' => 'admin'), function() {
Route::resource('tweets', 'TweetsController');
});
As was suggested in this stackoverflow question.
Using php artisan routes reveals that the named routes also now have admin prefixed to them, turning tweets.create into admin.tweets.create.
Why is the error saying that it cannot find tweets.create? shouldn't that automatically be resolved (judging by the routes table), to use admin.tweets.create?
How can I change my routing so that this error no longer occurs?
I just tested with new resource controller and it works fine for me.
The problem is not with the Route, its with the named routes used in your application.
check your view files there are link to route like link_to_route('tweets.create', 'Add new tweet'), this is creating the error because when you add admin as prefix tweets.create doesn't exists so change it to admin.tweets.create every where, in your controller also where ever named route is used.