<?php

namespace App\Http\Controllers\Admin\Config\Form;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Models\Config;

class TelegramController extends Controller
{
    private Config $configModel;

    public function __construct(Config $config)
    {
        $this->configModel = $config;
    }

    /**
     * 문자 양식
     * @method GET
     * @see /admin/config/form/email
     */
    public function index()
    {
        return view('admin.config.form.telegram', []);
    }

    /**
     * 문자 양식 저장
     * @method POST
     * @see /admin/config/form/email
     */
    public function store(Request $request)
    {
        $rules = [
            'send_sms_register_form_content' => 'string|nullable',
            'send_sms_changepw_form_content' => 'string|nullable',
            'send_sms_withdraw_form_content' => 'string|nullable',
            'send_sms_auth_form_content' => 'string|nullable',
            'send_sms_find_form_content' => 'string|nullable',
            'send_sms_post_form_content' => 'string|nullable',
            'send_sms_post_comment_form_content' => 'string|nullable',
            'send_sms_post_blame_form_content' => 'string|nullable',
            'send_sms_post_comment_blame_form_content' => 'string|nullable',
        ];

        $attributes = [

        ];

        $posts = $this->validate($request, $rules, [], $attributes);

        $this->configModel->save($posts);

        $message = '문자 양식 정보가 저장되었습니다.';
        return redirect()->route('admin.config.form.sms.index')->with('message', $message);
    }
}
