1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- <?php
- namespace App\Models;
- # use Illuminate\Database\Eloquent\Model;
- class Note extends Model
- {
- protected $table = "note";
- public function client()
- {
- return $this->hasOne(Client::class, 'id', 'client_id');
- }
- public function hcpPro()
- {
- return $this->hasOne(Pro::class, 'id', 'hcp_pro_id');
- }
- public function noteTemplate()
- {
- return $this->hasOne(NoteTemplate::class, 'id', 'note_template_id');
- }
- public function createdSession()
- {
- return $this->hasOne(AppSession::class, 'id', 'created_by_session_id');
- }
- public function allyPro()
- {
- return $this->hasOne(Pro::class, 'id', 'ally_pro_id');
- }
- public function bills()
- {
- return $this->hasMany(Bill::class, 'note_id', 'id')
- ->orderBy('id', 'asc');
- }
- public function addendums()
- {
- return $this->hasMany(NoteAddendum::class, 'note_id', 'id')->where('is_removed', false);
- }
- public function sections()
- {
- return $this->hasMany(Section::class, 'note_id', 'id')
- ->where('is_active', true)
- ->orderBy('position_index', 'asc');
- }
- public function reasons()
- {
- return $this->hasMany(NoteReason::class, 'note_id', 'id');
- }
- public function claims()
- {
- return $this->hasMany(Claim::class, 'note_id', 'id');
- }
- public function summary()
- {
- $parts = [];
- foreach ($this->sections as $section) {
- $parts[] = $section->summary_html;
- }
- $parts = array_map(function($_part) {
- return '<div class="note-section-summary">' . $_part . '</div>';
- }, $parts);
- return implode("", $parts);
- }
- public function hcpCompanyProPayer()
- {
- return $this->hasOne(CompanyProPayer::class, 'id', 'hcp_company_pro_payer_id');
- }
- }
|