Laravel 9 gives wrong validation error messages - laravel

I don't get the correct validation error messages, instead I get this dot-notation error message:
When I submit the empty form, the fabric error message shows validation.required instead of Fabric is required.
Here is my code:
$request->validate([
'fabric'=>'required|in:3'
]);

I deleted the old resources/lang folder and it worked.
Just remember to have the new lang folder, and its content, in your project root directory like this : https://github.com/laravel/laravel/tree/9.x/lang

Related

Livewire actions get 302 response

I have a laravel project deployed on a domain subfolder
https://example.com => another project
https://example.com/dashboard => my laravel project
I have set my livewire config asset_url to config('app.url'), which my .env's APP_URL is https://example.com/dashboard
It is a simple project that has an auth middleware which protect https://example.com/dashboard and redirect it to https://example.com/dashboard/login. And when I try to fill the input (it has wire:model attribute), I get an error at my JS console
Uncaught (in promise) SyntaxError: Unexpected token < in JSON at position 0 at JSON.parse (<anonymous>) at index.js:58
When I check the Network tab, there were some process:
https://example.com/dashboard/livewire/message/login (post) => 302 (i think it is not expected)
https://example.com/dashboard/login (get) => 200 (i think it makes the error above)
It works fine if I deploy it to https://example.com, but at https://example.com/dashboard it keeps getting this issue
Could you guys help me?
Take a look at the livewire.php config folder, maybe you have to change the path for the Livewire assets

Change default Laravel "Server error" message

I've noticed that in production mode with my debug mode set to false that most of my functions that have a try/catch will return the Laravel default "Server error" message.
I've been trying to hunt this message down with little luck, how can I customise this generic message returned from functions within my Laravel app whilst debug is turned off?
If you're referring to a very generic HTTP 500 error, it's a blade file in the framework.
If you want to display your own error for 5XX errors and such, you can override them by creating a blade file with the name of the error you want to override. For example:
resources/views/errors/500.blade.php
{{ __('Uh oh. Something has gone wrong behind the scenes.');
Now when a 500 error is encountered, your blade error will be displayed rather than the default Laravel 500 error.
You can create files for the common errors too obviously.
Update
The default messages for HTTPExceptions in Laravel are provided by the Symfony Response class found in the Symfony\Component\HttpFoundation directory.
When it comes to providing error messages in APIs, most will send the default HTTP status code in the headers and then supply a human error message in the response body.
For your example you might do something like:
return response()->json([
'errors' => [
[
'status' => 500,
'title' => 'Internal server error',
'message' => 'A more detailed error message to show the end user'
],
]
], 500);
You would then be responsible for consuming the error response and showing the end user the human readable error rather than the default generic Internal server error.
You might find some of the JSON API examples useful.
In my case, my Model extends Authenticable.
I changed it to Model and imported Eloquence.

ErrorException error issue in laravel how can i redirect this another custom error page

When I got an error in laravel site then i have received this error page.I want to redirect to another page which I have created custom looks like a valid error page.
enter image description here
enter image description here
First in your .env file (in your project's root) set false for app_debug ->
APP_DEBUG=false
Then create a file named 500.blade.php that contains your custom html css in (resources\views\errors)
Done.
(for others errors like 404 , 503 , just change the name of file to that error code)
More information Here

How to make debug page in laravel?

I have set mode in .env file as: APP_DEBUG = false;
Now when error is happen it shows empty page with header: "Error".
How to make separated page for that?
You create a template in the views/error folder with name after the error code you want it to handle see https://laravel.com/docs/5.4/errors#custom-http-error-pages
You can create Blade templates for specific HTTP error codes in resources/views/errors/xxx.blade.php. For instance you can make resources/views/errors/500.blade.php for Internal Server Errors or resources/views/errors/404.blade.php for instances where a page can not be found. More here: https://laravel.com/docs/5.4/errors#custom-http-error-pages

"Server Error" when users try to create a new account - Magento 1.7

I'm setting up our Magento 1.7 store, hoping to be ready for launch soon. I've noticed a problem:
When users try to create a new account, they fill out their info on /customer/account/create page just fine, then when they click submit, they get this 500 Error:
The website encountered an error while retrieving
http://example.com/customer/account/createpost/.
the account is actually created, however.
Similar deal on when users submit their email on the Forgot Password page, they press submit and get this:
The website encountered an error while retrieving
http://example.com/customer/account/forgotpasswordpost/.
no email is sent.
If you see this and know how to help with this prob, your advice would be much appreciated, truly.
In case it helps, we are using a theme, rather than default.
EDIT - (I was asked if I had checked server error)
My server errors show as this, for the above situations:
Forgot Password submit shows this error:
Fatal error: Call to undefined method Mandrill_API::addTo() in
D:\Magento\app\code\core\Mage\Core\Model\Email\Template.php on line
438
and
Create Account submit shows this error:
Fatal error: Call to undefined method Mandrill_API::addTo() in
D:\Magento\app\code\core\Mage\Core\Model\Email\Template.php on line
438
as well.
Here is 6 lines(437-442) of that Template.php file:
foreach ($emails as $key => $email) {
$mail->addTo($email, '=?utf-8?B?' . base64_encode($names[$key]) . '?=');
}
$this->setUseAbsoluteLinks(true);
$text = $this->getProcessedTemplate($variables, true);
[UPDATE]
I've learned that when I enter a random, fake email for Forgot Password, and press submit, a confirmation appears, saying something like "If this email exists, then a new email was sent to that email!", but when I submit an email of a real existing customer, then it gives me the 500 error I've mentioned.
Still nothing - if anyone out there sees this, and you have a bit of time to help solve this perhaps, may Talos bless you!
[SOLVED]
I turns out this was a problem with transaction emails.
Cause by an extension, Mandrill, which is added to magento when I installed the MailChimp extension, called "MageMonkey - MailChimp Integration by ebizmarts"
Once I enabled Mandrill, in config, advanced, all transactions and transaction emails work perfectly fine!
It's possible that it's a .htaccess or server configuration problem. Where is it hosted? Do you have a .htaccess file in the root of the installation?

Resources