1
0
Fork 0
medical-record-server/app/Admin/Services/PatientService.php

59 lines
1.3 KiB
PHP

<?php
namespace App\Admin\Services;
use App\ModelFilters\PatientFilter;
use App\Models\Patient;
use Illuminate\Support\Facades\Validator;
class PatientService extends BaseService
{
protected string $modelName = Patient::class;
protected array $withRelationships = ['doctor'];
protected string $modelFilterName = PatientFilter::class;
/**
* 处理表单数据
*
* @param array $data
* @return array
*/
public function resloveData($data)
{
return $data;
}
/**
* 表单验证
*
* @param array $data
* @param int $id 空: 添加, 非空: 修改
* @return mixed true: 验证通过, string: 错误提示
*/
public function validate($data, $id = null)
{
if (!$id) {
$validator = Validator::make($data, [
'name' => ['required'],
]);
if ($validator->fails()) {
return $validator->errors()->first();
}
}
return true;
}
/**
* 删除的前置方法
*
* @param array $ids 主键id
* @return mixed true: 继续后续操作, string: 中断操作, 返回错误提示
*/
public function preDelete(array $ids)
{
return true;
}
}