Skip to content

Commit

Permalink
add config file
Browse files Browse the repository at this point in the history
  • Loading branch information
Oscar Cabrera committed Jun 11, 2024
1 parent e1d56cd commit c8c2efc
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 3 deletions.
2 changes: 1 addition & 1 deletion config/json-api-format.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
/*
* The name of the macro that is added to the Eloquent query builder.
*/
'method_name' => 'applyFilters',
'method_name' => 'getFields',
];
55 changes: 55 additions & 0 deletions docs/usage/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,58 @@ composer require oscabrera/laravel-json-api-format-paginate

This command instructs Composer to download the `oscabrera/laravel-json-api-format-paginate` package from the Packagist
repository and include it in your project's dependencies.

### Publish the Configuration File:

The configuration file is optional, but provides additional flexibility by allowing you to change the name of the method
used to get the fields from the model. To publish the configuration file, run the following command:

```shell
php artisan vendor:publish --provider="Oscabrera\JsonApiFormatPaginate\JsonApiFormatPaginateServiceProvider" --tag="config"
```

This command will create a `config/json-api-format.php` file in your Laravel application. You can edit this file to adjust
the package settings.

### Configuration File Example

The published configuration file `config/json-api-format.php` will have the following content by default:

```php
return [
/*
* The name of the macro that is added to the Eloquent query builder.
*/
'method_name' => 'getFields',
];
```

### Purpose of Configuration File

The configuration file allows you to change the name of the method that is used to get the fields from the model. By
default, the method is called `getFields`, however, you can change this name depending on your
preferences or project needs.

## Others Configuration Files

### Json Api Paginate Configuration File

if you want to change the configurations of the pagination, you can edit the `config/json-api-paginate.php` file.

```shell
php artisan vendor:publish --provider="Spatie\JsonApiPaginate\JsonApiPaginateServiceProvider" --tag="config"
```

This command will create a `config/json-api-paginate.php` file in your Laravel application. You can edit this file to
adjust the package settings.

### Query Builder Configuration File

if you want to change the configurations of the query builder, you can edit the `config/query-builder.php` file.

```shell
php artisan vendor:publish --provider="Spatie\QueryBuilder\QueryBuilderServiceProvider" --tag="query-builder-config"
```

This command will create a `config/query-builder.php` file in your Laravel application. You can edit this file to adjust
the package settings.
4 changes: 2 additions & 2 deletions semver.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"version": "v1.0.0",
"last-update-type": "major"
"version": "v1.0.1",
"last-update-type": "patch"
}

0 comments on commit c8c2efc

Please sign in to comment.