|
|
|
|
@ -2,7 +2,9 @@
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\Admin;
|
|
|
|
|
|
|
|
|
|
use App\Helpers\ResponseCode;
|
|
|
|
|
use App\Models\AppointmentType;
|
|
|
|
|
use Illuminate\Support\Facades\Validator;
|
|
|
|
|
|
|
|
|
|
class AppointmentTypeController extends BaseController
|
|
|
|
|
{
|
|
|
|
|
@ -83,6 +85,41 @@ class AppointmentTypeController extends BaseController
|
|
|
|
|
*/
|
|
|
|
|
public function save()
|
|
|
|
|
{
|
|
|
|
|
$all = request()->all();
|
|
|
|
|
$messages = [
|
|
|
|
|
'name.required' => '类型名称必填',
|
|
|
|
|
'name.max' => '类型名称不能超过100字',
|
|
|
|
|
];
|
|
|
|
|
$validator = Validator::make($all, [
|
|
|
|
|
'id' => 'nullable|integer',
|
|
|
|
|
'name' => ['required', 'string', 'max:100', function ($attribute, $value, $fail) {
|
|
|
|
|
if (preg_match('/(select|insert|update|delete|pg_sleep|union|\/\*|\*\/|--|sleep\s*\()/i', $value)) {
|
|
|
|
|
$fail('名称包含非法字符');
|
|
|
|
|
}
|
|
|
|
|
}],
|
|
|
|
|
'introduce' => 'nullable|string|max:500',
|
|
|
|
|
'start_time' => ['nullable', 'regex:/^\d{2}:\d{2}$/'],
|
|
|
|
|
'end_time' => ['nullable', 'regex:/^\d{2}:\d{2}$/'],
|
|
|
|
|
'is_show' => 'nullable|in:0,1',
|
|
|
|
|
'is_book' => 'nullable|in:0,1',
|
|
|
|
|
'sort' => 'nullable|integer',
|
|
|
|
|
'total' => 'nullable|integer|min:0',
|
|
|
|
|
'floor' => 'nullable|string|max:50',
|
|
|
|
|
'image_id' => 'nullable|array',
|
|
|
|
|
'image_id.*' => 'integer',
|
|
|
|
|
'content' => 'nullable|string',
|
|
|
|
|
'tips' => 'nullable|string',
|
|
|
|
|
], $messages);
|
|
|
|
|
if ($validator->fails()) {
|
|
|
|
|
return $this->fail([ResponseCode::ERROR_PARAMETER, implode(',', $validator->errors()->all())]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$allowed = [
|
|
|
|
|
'id', 'name', 'introduce', 'start_time', 'end_time', 'is_show', 'is_book',
|
|
|
|
|
'sort', 'total', 'floor', 'image_id', 'content', 'tips',
|
|
|
|
|
];
|
|
|
|
|
request()->replace(array_intersect_key($all, array_flip($allowed)));
|
|
|
|
|
|
|
|
|
|
return parent::save();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|