110 lines
4.3 KiB
PHP
110 lines
4.3 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\Validator;
|
|
use Illuminate\Support\Facades\Mail;
|
|
|
|
class InquiryConfirmController extends Controller
|
|
{
|
|
// 初期表示内容
|
|
public $form_data = [
|
|
["name", "text", "氏名*", ""],
|
|
["email", "email", "メールアドレス*", ""],
|
|
["tel", "text", "電話番号*", ""],
|
|
["subject", "checkbox", "お問い合わせ概要*", ["定期契約について", "操作方法について", "支払方法について", "その他お問合せ"]],
|
|
["parking", "text", "お問い合わせ駐輪場名", ""],
|
|
["detail", "textarea", "お問い合わせ詳細*", ""],
|
|
];
|
|
|
|
// ヘッダー⇒お問い合わせ入力
|
|
public function index()
|
|
{
|
|
// 入力画面に遷移
|
|
return view('general.swo7_1',['form_data' => $this->form_data ]);
|
|
}
|
|
|
|
// お問い合わせ入力⇒お問い合わせ確認
|
|
public function confirm(Request $request)
|
|
{
|
|
// 入力チェック内容
|
|
$rules = [
|
|
'name' => 'required',
|
|
'email' => 'required',
|
|
'tel' => 'required',
|
|
'subject' => 'required',
|
|
'detail' => 'required',
|
|
];
|
|
|
|
// エラーメッセージ
|
|
$message = [
|
|
'name.required' => '名前を入力してください',
|
|
'email.required' => 'メールアドレスを入力してください',
|
|
'tel.required' => '電話番号を入力してください',
|
|
'subject.required' => 'お問い合わせ概要を選択してください',
|
|
'detail.required' => 'お問い合わせ詳細を入力してください',
|
|
];
|
|
|
|
// バリデーションチェック
|
|
$validator = Validator::make($request->all(), $rules, $message);
|
|
if ($validator->fails()) {
|
|
return redirect('swo7_1')
|
|
->withErrors($validator)
|
|
->withInput()
|
|
->with('before_subject', implode(',', (array) $request->input('subject', [])));
|
|
}
|
|
|
|
// 画面返却値
|
|
$input_data = [
|
|
["name", $request->input('name'), "氏名"],
|
|
["email", $request->input('email'), "メールアドレス"],
|
|
["tel", $request->input('tel'), "電話番号"],
|
|
["subject", implode(',', $request->input('subject')), "お問い合わせ概要"],
|
|
["parking", $request->input('parking'), "お問い合わせ駐輪場名"],
|
|
["detail", $request->input('detail'), "お問い合わせ詳細"],
|
|
];
|
|
|
|
// 確認画面に遷移
|
|
return view('general.swo7_2', ['input_data' => $input_data]);
|
|
}
|
|
|
|
// お問い合わせ確認⇒お問い合わせ入力(戻る)orお問い合わせ完了(送信)
|
|
public function complete(Request $request)
|
|
{
|
|
// 前の画面に戻る
|
|
if($request->input('back') == 'back'){
|
|
return redirect('swo7_1')
|
|
->withInput($request->all())
|
|
->with('before_subject', $request->input('subject'));
|
|
}
|
|
|
|
// 受付メール(利用者用)送信
|
|
Mail::send(["text" => 'emails.inquiry_user'], [
|
|
'name' => $request->input('name'),
|
|
'email' => $request->input('email'),
|
|
'tel' => $request->input('tel'),
|
|
'subject' => $request->input('subject'),
|
|
'parking' => $request->input('parking'),
|
|
'detail' => $request->input('detail'),
|
|
], function ($message) use ($request) {
|
|
$message->to($request->input('email'))->subject('【So-Manager】お問い合わせを受け付けました');
|
|
});
|
|
|
|
// 受付メール(管理者用)送信
|
|
Mail::send(["text" => 'emails.inquiry_manager'], [
|
|
'name' => $request->input('name'),
|
|
'email' => $request->input('email'),
|
|
'tel' => $request->input('tel'),
|
|
'subject' => $request->input('subject'),
|
|
'parking' => $request->input('parking'),
|
|
'detail' => $request->input('detail'),
|
|
], function ($message) use ($request) {
|
|
$message->to(config('env.mail_admin'))->subject('【So-Manager】お問い合わせ受信');
|
|
});
|
|
|
|
// 完了画面に遷移
|
|
return view('general.swo7_3');
|
|
}
|
|
} |