Skip to content
Snippets Groups Projects
PageModel.php 1.54 KiB
Newer Older
  • Learn to ignore specific revisions
  • <?php
    
    /**
     * @copyright  2020 Podlibre
     * @license    https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
     * @link       https://castopod.org/
     */
    
    namespace App\Models;
    
    
        protected $allowedFields = ['id', 'title', 'slug', 'content'];
    
    
        /**
         * @var string
         */
        protected $returnType = Page::class;
        /**
         * @var bool
         */
    
        protected $validationRules = [
            'title' => 'required',
            'slug' =>
    
                'required|regex_match[/^[a-zA-Z0-9\-]{1,191}$/]|is_unique[pages.slug,id,{id}]',
    
    
        /**
         * Before update because slug or title might change
         *
         * @var string[]
         */
    
         * @return array<string, array<string|int, mixed>>
         */
        protected function clearCache(array $data): array
    
            // Clear the cache of all pages
            cache()->deleteMatching('page*');