123456789101112131415161718192021222324252627282930313233343536373839 |
- <?php
- namespace App\Models;
- # use Illuminate\Database\Eloquent\Model;
- use Illuminate\Support\Collection;
- class CareMonth extends Model
- {
- protected $table = 'care_month';
- public function patient(){
- return $this->hasOne(Client::class, 'id', 'client_id');
- }
- public function mcp(){
- return $this->hasOne(Pro::class, 'id', 'mcp_pro_id');
- }
- public function entries() {
- return $this->hasMany(CareMonthEntry::class, 'care_month_id', 'id');
- }
- public function bills() {
- return $this->hasMany(Bill::class, 'care_month_id', 'id');
- }
- public function getBillsOfType($_type) {
- $bills = $this->bills;
- $targetBills = new Collection();
- foreach ($bills as $bill) {
- if($bill->cm_or_rm === $_type) {
- $targetBills->add($bill);
- }
- }
- return $targetBills;
- }
- }
|