|
@@ -4,6 +4,8 @@ namespace App\Models;
|
|
|
|
|
|
# use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
|
+use Illuminate\Support\Collection;
|
|
|
+
|
|
|
class CareMonth extends Model
|
|
|
{
|
|
|
protected $table = 'care_month';
|
|
@@ -20,4 +22,18 @@ class CareMonth extends Model
|
|
|
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;
|
|
|
+ }
|
|
|
}
|