'Draft', 'requested' => 'Requested', 'received' => 'Received', 'approved' => 'Approved', 'paid' => 'Paid', 'declined' => 'Declined' ]; protected static function boot() { parent::boot(); static::creating(function ($model) { try { $model->code = (string) Str::orderedUuid(); // generate uuid } catch (\Exception $e) { abort(500, $e->getMessage()); } }); } public function member() { return $this->belongsTo(Member::class, 'member_id'); } public function diagnosis() { return $this->belongsTo(Icd::class, 'diagnosis_id'); } public function plan() { return $this->belongsTo(Plan::class, 'plan_id'); } public function benefit() { return $this->belongsTo(Benefit::class, 'benefit_id'); } public function scopeUsed($query, $startDate, $endDate) { return $query ->whereIn('status', ['approved', 'paid']) ->whereBetween('requested_at', [$startDate, $endDate]); } }