'bool', ]; /** * @inheritdoc */ public function sluggable(): array { return ['slug' => ['source' => 'username']]; } /** * Get the User's goals. */ public function goals(): HasMany { return $this->hasMany(Goal::class); } /** * Get the User's journal entries. */ public function journalEntries(): HasMany { return $this->hasMany(JournalEntry::class); } /** * Get user's goal (if one exists) for a specific date. */ public function getGoalByDate(Carbon $date): ?Goal { $day = Goal::days()->firstWhere('dow', $date->format('N')); if (!$day) { throw new \BadMethodCallException("No day with `dow` value {$date->format('N')}."); } return $this->goals()->whereRaw("(days & {$day['value']}) != 0")->get()->first(); } /** * Defines conversions for the User image. * * @throws \Spatie\Image\Exceptions\InvalidManipulation * * @see https://spatie.be/docs/laravel-medialibrary/v9/converting-images/defining-conversions */ public function registerMediaConversions(Media $media = null): void { $this->addMediaConversion('icon') ->width(300) ->height(300) ->sharpen(10) ->optimize(); } }