|
11 | 11 | use App\Enums\EuPlatescStatus; |
12 | 12 | use App\Enums\ProjectStatus; |
13 | 13 | use App\Traits\HasProjectStatus; |
| 14 | +use App\Traits\HasValidDates; |
14 | 15 | use Embed\Embed; |
15 | 16 | use Illuminate\Database\Eloquent\Builder; |
16 | 17 | use Illuminate\Database\Eloquent\Factories\HasFactory; |
@@ -39,6 +40,7 @@ class Project extends Model implements HasMedia |
39 | 40 | use HasVolunteers; |
40 | 41 | use InteractsWithMedia; |
41 | 42 | use HasProjectStatus; |
| 43 | + use HasValidDates; |
42 | 44 | use HasSlug; |
43 | 45 | use LogsActivity; |
44 | 46 | use LogsActivityForApproval; |
@@ -192,14 +194,14 @@ public function getIsDraftAttribute(): bool |
192 | 194 |
|
193 | 195 | public function getIsPeriodActiveAttribute(): bool |
194 | 196 | { |
195 | | - return $this->start->isPast() && $this->end->isFuture(); |
| 197 | + return $this->start?->isPast() && $this->end?->isFuture(); |
196 | 198 | } |
197 | 199 |
|
198 | 200 | public function getIsActiveAttribute(): bool |
199 | 201 | { |
200 | 202 | return $this->status == ProjectStatus::approved |
201 | | - && $this->start->isPast() |
202 | | - && $this->end->isFuture(); |
| 203 | + && $this->start?->isPast() |
| 204 | + && $this->end?->isFuture(); |
203 | 205 | } |
204 | 206 |
|
205 | 207 | public function getCanBeArchivedAttribute(): bool |
@@ -249,7 +251,7 @@ public function markAsApproved(): bool |
249 | 251 | $slug .= '-' . ($count + 1); |
250 | 252 | } |
251 | 253 |
|
252 | | - $this->activities->map(fn (Activity $activity) => $activity->approve()); |
| 254 | + $this->activities->map(fn(Activity $activity) => $activity->approve()); |
253 | 255 |
|
254 | 256 | return $this->update([ |
255 | 257 | 'status' => ProjectStatus::approved, |
@@ -280,10 +282,10 @@ public function getEmbeddedVideosAttribute(): array |
280 | 282 | ->pluck('url') |
281 | 283 | ->filter() |
282 | 284 | ->map( |
283 | | - fn (string $videoUrl) => Cache::remember( |
| 285 | + fn(string $videoUrl) => Cache::remember( |
284 | 286 | 'video-' . hash('sha256', $videoUrl), |
285 | 287 | MONTH_IN_SECONDS, |
286 | | - fn () => rescue(fn () => (new Embed)->get($videoUrl)->code, report: false) |
| 288 | + fn() => rescue(fn() => (new Embed)->get($videoUrl)->code, report: false) |
287 | 289 | ) |
288 | 290 | ) |
289 | 291 | ->filter() |
|
0 commit comments