Skip to content

Commit

Permalink
Patient records 💉💉
Browse files Browse the repository at this point in the history
  • Loading branch information
end3r-man committed Nov 19, 2023
1 parent 655f5e8 commit 3261a56
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 1 deletion.
30 changes: 29 additions & 1 deletion app/Filament/Resources/PatientRecordResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,16 @@
use App\Filament\Resources\PatientRecordResource\RelationManagers;
use App\Models\PatientRecord;
use Filament\Forms;
use Filament\Forms\Components\DatePicker;
use Filament\Forms\Components\FileUpload;
use Filament\Forms\Components\Section;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Columns\ImageColumn;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
Expand All @@ -26,7 +33,28 @@ public static function form(Form $form): Form
{
return $form
->schema([
//
Section::make([
TextInput::make('name')
->label('Parent Name')
->required(),
TextInput::make('number')
->label('Parent Number')
->required(),
TextInput::make('address')
->label('Parent Address')
->required(),
Select::make('patient_id')
->label('Patient Name')
->relationship('patient', 'name')
->native(false)
->searchable()
->preload(),
FileUpload::make('doc_img')
->image()
->imageEditor()
->directory('/patient_doc')
->columnSpan(2)
])->columns(2)
]);
}

Expand Down
13 changes: 13 additions & 0 deletions app/Models/PatientRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,21 @@

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class PatientRecord extends Model
{
use HasFactory;

public function patient(): BelongsTo {
return $this->belongsTo(PatientView::class, 'patient_id');
}

protected $fillable = [
'name',
'number',
'address',
'doc_img',
'patient_id',
];
}
38 changes: 38 additions & 0 deletions database/migrations/2023_11_19_090733_create_patient_records.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

use App\Models\PatientView;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('patient_records', function (Blueprint $table) {
$table->id();
$table->foreignIdFor(PatientView::class, 'patient_id')
->nullable();
$table->string('name')
->nullable();
$table->string('number')
->nullable();
$table->text('address')
->nullable();
$table->string('doc_img')
->nullable();
$table->timestamps();
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('patient_records');
}
};

0 comments on commit 3261a56

Please sign in to comment.