*/ protected $allowedFields = ['id', 'title', 'slug', 'content_markdown', 'content_html']; /** * @var string */ protected $returnType = Page::class; /** * @var bool */ protected $useSoftDeletes = false; /** * @var bool */ protected $useTimestamps = true; /** * @var array */ protected $validationRules = [ 'title' => 'required', 'slug' => 'required|regex_match[/^[a-zA-Z0-9\-]{1,128}$/]|is_unique[pages.slug,id,{id}]', 'content_markdown' => 'required', ]; /** * @var list */ protected $afterInsert = ['clearCache']; /** * Before update because slug or title might change * * @var list */ protected $beforeUpdate = ['clearCache']; /** * @var list */ protected $beforeDelete = ['clearCache']; /** * @param mixed[] $data * * @return array> */ protected function clearCache(array $data): array { // Clear the cache of all pages cache() ->deleteMatching('page*'); return $data; } }