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

44 lines
1.0 KiB
PHP

<?php
namespace App\Admin\Services;
use App\ModelFilters\PatienRecordFilter;
use App\Models\PatientRecord;
use Illuminate\Support\Facades\Validator;
use Slowlyo\OwlAdmin\Admin;
class PatientRecordService extends BaseService
{
protected string $modelName = PatientRecord::class;
protected array $withRelationships = ['doctor', 'patient'];
protected string $modelFilterName = PatienRecordFilter::class;
public function listQuery()
{
$model = $this->getModel();
$filter = $this->getModelFilter();
$query = $this->query();
if ($this->withRelationships) {
$query->with($this->withRelationships);
}
if ($filter) {
$query->filter(request()->input(), $filter);
}
return $query->sort();
}
public function resloveData($data)
{
$creator_id = data_get($data, 'creator_id');
if (!$creator_id) {
$data['creator_id'] = data_get(Admin::user(), 'id');
}
return $data;
}
}