Laravel : mcamara/laravel-localization and nwidart/laravel-modules problem - laravel

I will explain my problem with visuals now, but I will write it first. I am using mcamara/laravel-localization and nwidart/laravel-modules packages. And each module has its own json file in it, the nwidart/laravel-modules file alone works and I translate the language extraction process as #lang('test').
Now example 1 (nwidart/laravel-modules active - mcamara/laravel-localization inactive):
My Site View
Example 2 (nwidart/laravel-modules active - mcamara/laravel-localization active but web.php edited):
My Site View
Route : My Route
Example 3 (nwidart/laravel-modules active - mcamara/laravel-localization active but no data in web.php):
My Site View
Route : My Route
My problem is: what is the language of the site when these codes are received, for example 'tr' or 'en' in config/app.php 'locale' => 'tr' does not read the json folder in modules for that language of the site.

Related

How to stop the GET method is not supported for this route from showing?

I have a working Laravel project with loads of different routes.
I'm currently testing it and one of my tests was to check if a user were to use a delete or post route from the URL. I didn't know what the application would do honestly and it outputted the typical:
The GET method is not supported for this route. Supported methods: DELETE
which I have seen a million times. Is there a way to stop this error from coming up and instead output an error screen or simply redirect to a different view?
The error message:
The GET method is not supported for this route. Supported methods: DELETE.
should only appear when your Laravel site has APP_DEBUG set to true (in the .env file).
When APP_DEBUG is set to false as it should always be in on a live site, then the user will be shown a 404 error page instead.
You can easily test this by adding the following code to your routes file:
Route::delete('test', function() {
return 'You should never see this text when viewing url via a GET request';
});
May be u didn't noticed but ur form tag method attribute and route definition is different

Modify the URL generated with Route::apiResource without changing the name

I'm building a website where users can post ads : a VueJS app that requests routes on an Laravel API.
I have an AdController, with an Ad model, and my routing is done via stuff like :
Route::apiResource('ads', AdController::class)->only(['update', 'destroy']);
Route::apiResource('ads.photos', AdPhotoController::class)->only(['index']);
which generates routes like PUT "/ads/{ad}" or GET "/ads/{id}/photos"....
This works very well, and my VueJS app uses Ziggy to call the API by their route name
axios.get(route('ads.photos.index', id))
And... It still works flawlessly ! No problem at all, and I have a LOT of routes with a LOT of API calls.
Now my problem : we realised that URLs containing "ads" are blocked by adblockers. That completely shuts down all access to our website, and asking users to turn off the adblocker is NOT a solution.
I could change my routes to do something like
Route::apiResource('posts.photos', AdPhotoController::class)->only(['index']);
but I have a LOT of routes and I really don't want to rename everything, everywhere.
Is there an option to change apiResources generated URL, so 'ads.photos.index' would generate "/posts/{id}/photos" instead of "/ads/{id}/photos" ?

TYPO3 force internal links to cross domain pages to use https in news

my TYPO3 website has multiple domains that have links from internal news to another a page in another domain.
Domain A (with SSL in frontend)
Page 1
News (folder)
News A
News B
Domain B (with SSL in frontend)
Page 2
Page 3
Links in News A to Page 1 work perfectly fine, but when linking from News B to Page 2 or Page 3, the url is generated properly, but the scheme is always http:
Example News A:
Page 1
Example News B: Page 2
Is there a way to configure the url generation to always use https as scheme when linking to anything in a given domain? I suspect that this has to be done for the link rendering in tx_news?
This has nothing to do with the news extension but is a bug in TYPO3 itself - or let's call it a missing feature because TYPO3 doesn't know at this place that the other domain should be use https as protocol.
What I do to solve this is a replace on the content before it is outputted. This can be done with adding a hook in the ext_localconf.php:
// Hook for changing output before showing it
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['contentPostProc-output'][]
= \Vendor\ExtKey\Hooks\Frontend\ContentPostProc::class . '->run';
and in the file typo3conf/extkey/Classes/Hooks/Frontend/ContentPostProc:
namespace Vendor\ExtKey\Hooks\Frontend;
class ContentPostProc
{
public function run(array &$parameters) {
$searchReplace = [
'http://domain.tld' => 'https://domain.tld'
];
$parameters['pObj']->content = str_replace(array_keys($searchReplace), array_values($searchReplace), $parameters['pObj']->content);
}
}

How to call sitemap.xml in codeigniter application

i have added sitemap.xml file to my codeigniter project.
And i call it on my localhost like that : http://localhost/demo/sitemap.xml
it runs without any issue.
But when i run it on live server http://example.com/demo/sitemap.xml
it says 404 page not found.
What is issue ?
you need to add below things in your config/routes.php file
$route['sitemap\.xml'] = 'demo/sitemap'; // your navigation path i.e. your controller_name/function_name

Laravel 4 - changing resource root routing path

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.

Resources