-
Notifications
You must be signed in to change notification settings - Fork 0
/
Relation
88 lines (71 loc) · 3.14 KB
/
Relation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php
namespace App\Models\backend;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Prescription extends Model
{
use HasFactory;
protected $fillable = ['prescription_code','prescription_p_id','prescription_doc_id', 'prescription_history','prescription_note','prescription_date'];
public function doctor()
{
return $this->belongsTo(Doctors::class,'prescription_doc_id', 'id');
}
public function PressMedicine()
{
return $this->hasMany(Prescription_Medicines::class);
}
public function Presstest()
{
return $this->hasMany(PrescriptionTest::class);
}
public function inpatient()
{
return $this->belongsTo(InPatient::class, 'prescription_p_id', 'id');
}
public function outpatient()
{
return $this->belongsTo(OutPatient::class, 'prescription_p_id', 'id');
}
// public function medicines()
// {
// return $this->belongsToMany(Medicine::class)->using(Prescription_Medicines::class);
// }
}
Blade=======
<td>
@if ($Prescription->prescription_patient_type == 'inpatient')
{{$Prescription['inpatient']['in_p_name']}}
@elseif($Prescription->prescription_patient_type == 'outpatient')
{{$Prescription['outpatient']['out_p_name']}}
@endif
</td>
<td> {{ $Prescription['doctor']['doc_name'] }}</td>
<td>
@php
$med = '';
@endphp
@foreach ($Prescription['PressMedicine'] as $item)
@php
$med .= $item['medicine']['name'] . ', ';
@endphp
@endforeach
{{ $med }}
</td>
Migration
public function up()
{
Schema::create('subscriptions', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('plan_id');
$table->string('tocken');
$table->unsignedBigInteger('somity_id')->default(0);
$table->unsignedBigInteger('user_id')->default(0);
$table->integer('is_active')->default(0);
$table->integer('created_user_id')->default(0);
$table->integer('updated_user_id')->default(0);
$table->timestamps();
$table->foreign('somity_id')->references('id')->on('somities');
$table->foreign('plan_id')->references('id')->on('subscription_plans');
$table->foreign('user_id')->references('id')->on('users');
});
}