Skip to content

Commit

Permalink
fix empty strings
Browse files Browse the repository at this point in the history
  • Loading branch information
gheorghelupu17 committed Oct 9, 2023
1 parent a332997 commit da0d3c0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 6 additions & 0 deletions app/Models/Project.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ public function getCoverImageAttribute(): string

public function getPercentageAttribute(): float
{
if ($this->target_budget == 0) {
return 0;
}
return min(100, $this->total_donations / $this->target_budget * 100);
}

Expand All @@ -163,6 +166,9 @@ public function getIsActiveAttribute(): bool

public function getIsEndingSoonAttribute(): bool
{
if (empty($this->end)) {
return false;
}
return $this->end->diffInDays(today()) <= 5;
}
}
3 changes: 2 additions & 1 deletion app/Traits/HasProjectStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,11 @@ public function scopeWhereStartsSoon(): Builder
->whereDate('start', '>=', now())
->orderBy('start');
}

public function scopeStatusIs($status): Builder
{
// dd($status);
return match ($status){
return match ($status) {
'pending' => $this->whereIsPending(),
'approved' => $this->whereIsApproved(),
'rejected' => $this->whereIsRejected(),
Expand Down

0 comments on commit da0d3c0

Please sign in to comment.