|
@@ -8,6 +8,13 @@ class Point extends Model
|
|
|
{
|
|
|
protected $table = 'point';
|
|
|
|
|
|
+ public function childReviews()
|
|
|
+ {
|
|
|
+ return $this->hasMany(Point::class, 'parent_point_id', 'id')
|
|
|
+ ->where('category', 'REVIEW')
|
|
|
+ ->orderBy('created_at', 'DESC');
|
|
|
+ }
|
|
|
+
|
|
|
public function lastChildReview()
|
|
|
{
|
|
|
return $this->hasOne(Point::class, 'id', 'last_child_review_point_id');
|
|
@@ -18,6 +25,13 @@ class Point extends Model
|
|
|
return $this->hasOne(Note::class, 'id', 'last_child_review_point_scoped_note_id');
|
|
|
}
|
|
|
|
|
|
+ public function childPlans()
|
|
|
+ {
|
|
|
+ return $this->hasMany(Point::class, 'parent_point_id', 'id')
|
|
|
+ ->where('category', 'PLAN')
|
|
|
+ ->orderBy('created_at', 'DESC');
|
|
|
+ }
|
|
|
+
|
|
|
public function lastChildPlan()
|
|
|
{
|
|
|
return $this->hasOne(Point::class, 'id', 'last_child_plan_point_id');
|
|
@@ -28,6 +42,16 @@ class Point extends Model
|
|
|
return $this->hasOne(Note::class, 'id', 'last_child_plan_point_scoped_note_id');
|
|
|
}
|
|
|
|
|
|
+ public function client()
|
|
|
+ {
|
|
|
+ return $this->hasOne(Client::class, 'id', 'client_id');
|
|
|
+ }
|
|
|
+
|
|
|
+ public function note()
|
|
|
+ {
|
|
|
+ return $this->hasOne(Note::class, 'id', 'added_in_note_id');
|
|
|
+ }
|
|
|
+
|
|
|
public static function getGlobalSingletonOfCategory(Client $_patient, String $_category, $_assoc = false) {
|
|
|
$point = Point
|
|
|
::where('client_id', $_patient->id)
|