Skip to content

Instantly share code, notes, and snippets.

@kirkbushell
Created August 27, 2023 12:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kirkbushell/935e0529d809bd18178b4e497f7aedf9 to your computer and use it in GitHub Desktop.
Save kirkbushell/935e0529d809bd18178b4e497f7aedf9 to your computer and use it in GitHub Desktop.
Updated syntax for supporting caches in Eloquence
<?php
use Eloquence\Behaviours\CountCache\CountedBy;
use Eloquence\Behaviours\CountCache\HasCounts;
use Illuminate\Database\Eloquent\Model;
class Post extends Model {
use HasCounts;
#[CountedBy]
public function author(): BelongsTo
{
return $this->belongsTo(Author::class);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment