Skip to main content

Repository Configurations

Repository configurations are used to define default behaviors or values, also it locates all defined repositories in the project.

General Repository Configurations#

Repository has some featuring Configurations for more customrimzation, these configurations are located in config/mongez.php

config/mongez.php
/*
|--------------------------------------------------------------------------
| Repository Options
|--------------------------------------------------------------------------
|
| List of repository options located here
|
|--------------------------------------------------------------------------
| Uploads configurations
|--------------------------------------------------------------------------
|
| Setting the uploads directory will be useful when dealing with git repositories to be ignored.
| If sets to null, then it won't be used
|
| This directory will be created inside local directory path in the `config/filesystem.php`
|
| keepUploadsName:
| If set to true, then all uploads names wil be kept as it is.
| If set to false, a random generated hashed name will be used instead.
|
|--------------------------------------------------------------------------
| Cache configurations
|--------------------------------------------------------------------------
| When enabling caching in repositories, set the driver that will be used
| Available drivers are the available ones in Laravel config/cache.php drivers list
|
|--------------------------------------------------------------------------
| Pagination configurations
|--------------------------------------------------------------------------
| Pagination configurations work with `list` method in any repository.
|
| Any value listed below will be applied on all repositories unless repository/method-call override.
|
*/
'repository' => [
'cache' => [
'driver' => '',
],
'publishedColumn' => 'published',
'uploads' => [
'uploadsDirectory' => 'data',
'keepUploadsName' => true,
],
'pagination' => [
'paginate' => true,
'itemsPerPage' => 15,
],
],

Let's go for it one by one

  • cache
  • publishedColumn: Defines the boolean published column name to be used with the following methods:
    • listPublished: list all published records.
    • getPublished: Get the record, only if its publsihed column is true.

      Default value is published

  • uploads
    • uploadsDirectory: Determine the base uploads directory name that will contain all repositories uploads.

      Please note that uploads are using the Uploaded File StoreAs method , which appends the uploads directory to the base storage path.

    • keepUploadsName: If set to true, then the original file name will be remained, otherwise a random string name will be used instead.
  • pagination
    • paginate: If set to true, then all list methods will be paginated by default.
    • itemsPerPage: Defines default records per page when using the paginate option in any of the repository list methods, default is 15.
info

Please note that all of these configurations can be overriden from the repository class itself or by passing values to the list methods calls

Repositories List#

All repositories are defined in the repositories key in the configurations file, it looks like:

config/mongez.php
/*
|--------------------------------------------------------------------------
| Application Repositories
|--------------------------------------------------------------------------
|
| The repositories section will be mainly used for records retrieval... fetching records from database
| It will also be responsible for inserting/updating and deleting from database
|
*/
'repositories' => [
// add your repositories here
// 'repo-alias-name' => RepositoryClassPath::class,
'users' => App\Modules\Users\Repositories\UsersRepository::class,
// Auto generated repositories here: DO NOT remove this line.
],

The repositories key is an array, each key of it is the repository alias name, and its value is the repository class name.