How to display multibyte character flash message in Laravel7 - laravel

I'm studing contact form with flash message.
Laravel Framework version is 7.15.0
I can display flash message using below Contoller code.
\Mail::send('mail', array(
'name' => $request->get('name'),
'email' => $request->get('email'),
'phone' => $request->get('phone'),
'subject' => $request->get('subject'),
'user_query' => $request->get('message'),
), function($message) use ($request){
$message->from($request->email);
$message->to('mymail#mydomain.com', 'Admin')->subject($request->get('subject'));
});
return back()->with('success', 'We have received your message and would like to thank you for writing to us.');
}
I would like to change the flash message as Japanese like below code.
return back()->with('送信完了', 'ありがとうございました');
however I couldn't get flash message.
I tried as dobule quote version below but it won't show message.
return back()->with("送信完了", "ありがとうございました");
Could you teach me what is wrong my code please?

try this code
return back()->with('success', 'ありがとうございました');

Related

Laravel mail Email subjce is alwasy empty

I'm studying contact from.
this is working great but one thing. email subject is always empty.
I wrote below code. Could someone teach me right code right?
Contact::create($request->all());
\Mail::send('mail', array(
'phone' => $request->get('phone'),
), function($message) use ($request){
$message->from($request->email);
$message->to('mail#mmmmail.com', 'subject title')->bcc('mail2#mmmmail.com')->subject($request->get('subject title'));
});

How I can add error message in Laravel validate?

Help plz. "How add error user mistake in laravel" I want show JSON file - error $regex - reqular rules
I need get mistake on not correct sourceUrl
$this->validate($request,[
'title' => 'required|min:10|max:250', //work
'subTitle' =>'sometimes|present|nullable|min:10|max:250', //work
'message' => 'required|min:10',//work
'recommendPic' => 'present|nullable', //work
'pic' => 'required|sometimes', //file - check upload file,image need fix
'sourceUrl' =>'required|regex:'.$regex,
],[
'sourceUrl.regex:'.$regex=>'mistake',
]);
You need to return your failed validation messages, something like the following:
$validation = Validator::make($request->all(), [
'title' => 'required|min:10|max:250', //work
'subTitle' =>'sometimes|present|nullable|min:10|max:250', //work
'message' => 'required|min:10',//work
'recommendPic' => 'present|nullable', //work
'pic' => 'required|sometimes', //file - check upload file,image need fix
'sourceUrl' =>'required|regex:'.$regex,
]);
// if validation fails
if ($validation->fails()) {
return response()->json([
'status' => 'failure',
'errors' => $validation->errors()
], 400);
}
// validation passes
return response()->json(['status' => 'success'], 200);
'sourceUrl.regex:'.$regex=>'mistake', is not valid PHP code.
It should be something like: 'sourceUrl.regex' => 'regex mistake'
This redirects back with the error message regex mistake.
In your view you can print the message with #error('sourceUrl') {{ $message }}#enderror.

Laravel exceptions not working at all. It return phpinfo.php in every case

Hi guys i'm working with laravel 5.6, i have enabled debugging in .env but still it is not returning any exception and error.
instead of any error or exception it shows a complete page of phpinfo.php
here is an example image what i am actually getting
https://www.hostinger.com/tutorials/wp-content/uploads/sites/2/2017/03/inside-the-php-info-section.png
Let me show you my code
public function store(Request $request)
{
$request->validate([
'first_name' => 'required|min:3',
'last_name' => 'required|min:3',
]);
...
}
the desired output was that if i have not entered any field i.e first_name or last_name it should provide an error that first_name or last_name is required but instead of this it return complete phpinfo.php page
Although the code sample you have provided does not have any error
I think you should try using the validation like this
$this->validate($request, [
'first_name' => 'required|min:3',
'last_name' => 'required|min:3',
]);
If you still face the error please try commenting you validation code for instance or using a dd() after validation so that we could ensure that the error is in the validation part or somewhere else.

laravel5.2 Mailgun work but not send the email

Hello I setup mailgun correctly. and did form contact us.
To send the message to my email by this code
public function send_contact_us()
{
$data = array(
'name' => Request::get('name'),'email'=>Request::get('email'),'subject'=> Request::get('subject'));
$client_m=Request::get('message');
$data_message=array('message_c'=>$client_m);
echo "we above MAIL";
Mail::send('emails.message',$data_message, function ($message)use ($data) {
$message->from($data['email'], 'E-SHOPPER');
$message->to("azharnabil013#yahoo.com")->subject($data['subject']);
});
return view('contact_us', array('title' => 'Welcome', 'description' => '', 'page' => 'contact_us','subscribe'=>'','sent'=>"Message has been sent successfuly"));
}
The code run correctly and this page display
But when I check my email I didn't find any message
I don't know why this problem .please, anyone help me.

Do custom error messages in Laravel 4.2

I'm new in Larvel 4.2 here! How do I do a custom error messages in Laravel 4.2? And where do I put these codes? I've been using the defaults and I kind of wanted to use my own.
Did you try something? http://laravel.com/docs/4.2/validation#custom-error-messages
Did you use Google? Check the documentation (official) it has everything. Be less lazy.
$messages = array(
'required' => 'The :attribute field is required.',
);
$validator = Validator::make($input, $rules, $messages);
To add to the answer given by slick, here is how you could use it in a real example of a store function inside a controller:
public function store(Request $request)
{
$validator = Validator::make($request->all(), [
'id1' => 'required|between:60,512',
'id2' => 'required|between:60,512',
'id3' => 'required|unique:table',
], [
'id1.required' => 'The first field is empty!',
'id2.required' => 'The second field is empty!',
'id3.required' => 'The third field is empty!',
'id1.between' => 'The first field must be between :min - :max characters long.',
'id2.between' => 'The second answer must be between :min - :max characters long.',
'id3.unique' => 'The third field must be unique in the table.',
]);
if ($validator->fails()) {
return Redirect::back()
->withErrors($validator)
->withInput();
}
//... Do something like store the data entered in to the form
}
Where the id should be the ID of the field in the form you want to validate.
You can check out all the rules you can use here.

Resources