# Example Configuration Template

```
<?php
return [

  /* Generic and general configurations */
  'general' => [
    'route' => [
      'name_prefix' => '',
      'slug_prefix' => 'models/'
    ],
    'security' => [
      'allow_guests' => false,
      'gate' => 'admin'
    ]
  ],

  /* Specifically enabled models */
  'models' => [

    /* The key of this array is the slug that is going to be used */
    'user' => [

      'model' => \App\User::class,

      'enabled' => ['collection', 'resource', 'post', 'put', 'patch', 'delete'],

      /* Alias field names */
      'aliases' => [
        'last-opened-email' => 'last_opened_email_at'
      ],

      /* You can specify security configurations here, and use them everywhere they're not specified for this model */
      'security' => [
        'gate' => 'admin',
        'policy' => 'manage'
      ],

      /* Global Transformations */
      'transformation' => [
        'resource' => Resource::class,
        'collection' => Collection::class,
        'modifier' => Modifier::class,
      ],

      /* Global Events */
      'events' => [
          ModifiedViaBakery::class,
      ],

      /* Browse (search and filter) */
      'browse' => [

        /* If we want to modify the query, for example to support tenancy, define it here */
        'query_modifier' => \App\Repository\QueryModifier::class,

        /* Do we allow guests to browse this endpoint */
        'allow_guests' => false,

        /* Use a gate to determine whether or not someone can browse this model */
        'gate' => 'admin',

        /* What collection should we use for results */
        'collection' => MyRecourceCollection::class,

        /* Search configurations */
        'search' => [

          /* On which columns can we do a fluffy search */
          'columns' => ['name','email'],

          /* If we have any custom search handlers, define them here, in execution order */
          'customHandlers' => [
            UserSearchHandler::class
          ],
          
          /* Caching */
          'cache' => [
            'enabled' => true,
            'ttl' => 600
          ]
          
        ],

        /* Filtering is for exact matching */
        'filter' => [
          'columns' => [
            'status', 
            'email_verified_at'
          ],
          'custom' => [
            'has-orders' => HasOrdersFilter::class
          ]
        ],

        /* Which fields do we allow ordering by */
        'order_fields' => [
          'created_at',
        ]
        
      ],

      /* Read a single model */
      'read' => [
        'security' => [
          'policy' => 'read',
          'gate' => 'admin'
        ],
        'resource' => MyResource::class
      ],

      /* Create new model */
      'post' => [

        /* Security configurations */
        'security' => [
          'policy' => 'create',
          'gate' => 'admin'
        ]

        /* Generators are responsible for instantiation of a fresh model */
        'generator' => Generator::class,

        /* Modifier is used immediate before save */
        'modifier' => Modifier::class,

        /* Resource to return - if we want to return a resource/transformed instance of this model after creation */
        'resource' => Resource::class,

        /* What fields shall we either explicitly populate or explicitly exclude */
        'fields' => [
          'populate' => ['name', 'email'],
          'exclude' => ['password']
        ],

        /* Fire these events */
        'events' => [
          EventOne::class
        ],

        /* Validation */
        'validator' => ProvidesValidation::class,
        
      ],

      /* Update a model */
      'put' => [

        /* Security configurations */
        'security' => [
          'gate' => 'admin',
          'policy' => 'update'
        ],

        /* Validation */
        'validator' => Validator::class,

        /* Field Settings */
        'fields' => [
          'accept' => ['name', 'email'],
          'nullify' => ['avatar'],
          'reject' => ['password']
        ],

        /* Modifier */
        'modifier' => ClassBeforeSave::class,


        /* Events */,
        'events' => [
          EventOne::class
        ],
      
      ],

      /* Partially update a model */
      'patch' => [
      
        /* Security configurations */
        'security' => [
          'gate' => 'admin',
          'policy' => 'update'
        ],

        /* Validation */
        'validator' => Validator::class,

        /* Fields */
        'accept' => ['name', 'email'],

        /* Modifier */
        'modifier' => ClassBeforeSave::class,


        /* Events */,
        'events' => [
          EventOne::class
        ],
        
      ]

      /* Delete a model */
      'delete' => [

          /* Security Configurations */
          'security' => [
            'gate' => 'admin',
            'policy' => 'delete'
          ],

          /* Events */,
          'events' => [
            EventOne::class
          ],
          
      ]
    ]

    
  ]
];
```
