<?php

namespace Modules\Mall\Http\Requests\Shop;

use Illuminate\Foundation\Http\FormRequest;
use Modules\Mall\Rules\CityRule;
use Modules\Mall\Rules\DistrictRule;
use Modules\Mall\Rules\ProvinceRule;

class ShopRequest extends FormRequest
{

    public function rules(): array
    {
        return [
            'name'        => 'required|unique:mall_shops',
            'mobile'      => 'required|phone:CN|unique:mall_shops',
            'description' => 'required',
            'province_id' => ['required', 'integer', new ProvinceRule()],
            'city_id'     => ['required', 'integer', new CityRule()],
            'district_id' => ['required', 'integer', new DistrictRule()],
            'address'     => 'required',
            'cover'       => 'required',
        ];
    }

    public function messages(): array
    {
        return [
            'name.required'        => '店铺名称必须填写',
            'name.unique'          => '店铺名称不能重复',
            'mobile.required'      => '联系方式必须填写',
            'mobile.phone'         => '联系方式格式不正确',
            'mobile.unique'        => '联系方式不能重复',
            'description.required' => '店铺简介必须填写',
            'province_id.required' => '店铺所在省份必须选择',
            'province_id.integer'  => '店铺所在省份格式不正确',
            'city_id.required'     => '店铺所在城市必须选择',
            'city_id.integer'      => '店铺所在城市格式不正确',
            'district_id.required' => '店铺所在地区必须选择',
            'district_id.integer'  => '店铺所在地区格式不正确',
            'address.required'     => '店铺详细地址必须填写',
            'cover.required'       => '店铺封面图必须上传',
        ];
    }

}
