
CTO at @testcard Building @matchdaysfans Code and Camera stuff!
- Tweets15.9K
- Following3K
- Followers572
- Likes4.2K
![enum UserMetric: string { case Logins = 'logins'; } enum MailboxMetric: string { case ProcessedEmails = 'processed_emails'; } trait HasMetrics { public function metrics() { return $this->morphMany(Metric::class, 'model'); } public function incrementMetric($name, $value = 1, $month = null, $year = null) { $this->metrics()->firstOrCreate([ 'name' => $name, 'month' => $month ?? now()->month, 'year' => $year ?? now()->year, ], ['value' => 0])->increment('value', $value); } public function decrementMetric($name, $value = 1, $month = null, $year = null) { $this->metrics()->where([ 'name' => $name, 'month' => $month ?? now()->month, 'year' => $year ?? now()->year, ])->first()?->decrement('value', $value); } }](https://pbs.twimg.com/media/GE-xHjnW8AA6fpe.jpg?name=small&format=webp)
ALT enum UserMetric: string { case Logins = 'logins'; } enum MailboxMetric: string { case ProcessedEmails = 'processed_emails'; } trait HasMetrics { public function metrics() { return $this->morphMany(Metric::class, 'model'); } public function incrementMetric($name, $value = 1, $month = null, $year = null) { $this->metrics()->firstOrCreate([ 'name' => $name, 'month' => $month ?? now()->month, 'year' => $year ?? now()->year, ], ['value' => 0])->increment('value', $value); } public function decrementMetric($name, $value = 1, $month = null, $year = null) { $this->metrics()->where([ 'name' => $name, 'month' => $month ?? now()->month, 'year' => $year ?? now()->year, ])->first()?->decrement('value', $value); } }




















![// Avoid. useEffect(() => { // do stuff }, []) // Prefer. Now intent is documented. useEffect(function connectUserToChat() { // do stuff }, [])](https://pbs.twimg.com/media/GEy7l09XYAAHlyV.jpg?name=small&format=webp)