* закончил окно редактирования карты с назначением номера в архиве
* добавил окно для редактирования выдачи / возврата карты * раздробил логику хранения карты
This commit is contained in:
21
app/Http/Controllers/ArchiveHistoryController.php
Normal file
21
app/Http/Controllers/ArchiveHistoryController.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\ArchiveHistory;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ArchiveHistoryController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function show($id, Request $request)
|
||||
{
|
||||
$archiveHistory = ArchiveHistory::find($id);
|
||||
|
||||
return response()->json($archiveHistory);
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Resources\ArchiveHistoryResource;
|
||||
use App\Models\SI\SttMedicalHistory;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -15,11 +16,13 @@ class MedicalHistoryController extends Controller
|
||||
$patientInfo = null;
|
||||
if ($viewType == 'si') {
|
||||
$patient = SttMedicalHistory::where('id', $id)->first();
|
||||
$archiveJournal = $patient->archiveHistory;
|
||||
$archiveJournal = ArchiveHistoryResource::collection($patient->archiveHistory);
|
||||
$archiveInfo = $patient->archiveInfo;
|
||||
|
||||
$patientInfo = [
|
||||
'info' => $patient,
|
||||
'journal' => $archiveJournal,
|
||||
'archiveInfo' => $archiveInfo,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
16
app/Http/Controllers/OrgController.php
Normal file
16
app/Http/Controllers/OrgController.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Org;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class OrgController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$orgs = Org::all(['id', 'name', 'code']);
|
||||
|
||||
return response()->json($orgs);
|
||||
}
|
||||
}
|
||||
30
app/Http/Resources/ArchiveHistoryResource.php
Normal file
30
app/Http/Resources/ArchiveHistoryResource.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
class ArchiveHistoryResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'issue_at' => Carbon::parse($this->issue_at)->format('d.m.Y'),
|
||||
'return_at' => Carbon::parse($this->return_at)->format('d.m.Y'),
|
||||
'comment' => $this->comment,
|
||||
'org_id' => $this->org_id,
|
||||
'org' => $this->org->name,
|
||||
'employee_name' => $this->employee_name,
|
||||
'employee_post' => $this->employee_post,
|
||||
'has_lost' => $this->has_lost,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -22,4 +22,9 @@ class ArchiveHistory extends Model
|
||||
{
|
||||
return $this->morphTo();
|
||||
}
|
||||
|
||||
public function org(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Org::class);
|
||||
}
|
||||
}
|
||||
|
||||
21
app/Models/ArchiveInfo.php
Normal file
21
app/Models/ArchiveInfo.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ArchiveInfo extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'historyable_type',
|
||||
'historyable_id',
|
||||
'num',
|
||||
'post_in',
|
||||
'status_id'
|
||||
];
|
||||
|
||||
public function historyable()
|
||||
{
|
||||
return $this->morphTo();
|
||||
}
|
||||
}
|
||||
16
app/Models/ArchiveStatus.php
Normal file
16
app/Models/ArchiveStatus.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ArchiveStatus extends Model
|
||||
{
|
||||
public $timestamps = false;
|
||||
|
||||
protected $fillable = [
|
||||
'text',
|
||||
'variant',
|
||||
'has_user_set'
|
||||
];
|
||||
}
|
||||
@@ -7,6 +7,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
class Org extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'code',
|
||||
'name'
|
||||
];
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Models\SI;
|
||||
|
||||
use App\Models\ArchiveHistory;
|
||||
use App\Models\ArchiveInfo;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class SttMedicalHistory extends Model
|
||||
@@ -33,6 +34,11 @@ class SttMedicalHistory extends Model
|
||||
return $this->morphMany(ArchiveHistory::class, 'historyable');
|
||||
}
|
||||
|
||||
public function archiveInfo()
|
||||
{
|
||||
return $this->morphOne(ArchiveInfo::class, 'historyable');
|
||||
}
|
||||
|
||||
public function scopeSearch($query, $searchText)
|
||||
{
|
||||
return $query->where(function($q) use ($searchText) {
|
||||
|
||||
Reference in New Issue
Block a user