From a21df5d7b80b6f82b40c6fe2732428fa52f99623 Mon Sep 17 00:00:00 2001 From: I Wayan Rupadana Date: Sat, 26 Aug 2023 15:47:09 +0800 Subject: [PATCH] update readme.md --- README.md | 61 ++++++++++++++++++++++++------------------------------- 1 file changed, 27 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index 57aabbd..3d5feda 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,9 @@ # A simple api service for supporting filamentphp [![Latest Version on Packagist](https://img.shields.io/packagist/v/rupadana/filament-api-service.svg?style=flat-square)](https://packagist.org/packages/rupadana/filament-api-service) -[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/rupadana/filament-api-service/run-tests.yml?branch=main&label=tests&style=flat-square)](https://github.com/rupadana/filament-api-service/actions?query=workflow%3Arun-tests+branch%3Amain) [![GitHub Code Style Action Status](https://img.shields.io/github/actions/workflow/status/rupadana/filament-api-service/fix-php-code-style-issues.yml?branch=main&label=code%20style&style=flat-square)](https://github.com/rupadana/filament-api-service/actions?query=workflow%3A"Fix+PHP+code+style+issues"+branch%3Amain) [![Total Downloads](https://img.shields.io/packagist/dt/rupadana/filament-api-service.svg?style=flat-square)](https://packagist.org/packages/rupadana/filament-api-service) -This is where your description should go. Limit it to a paragraph or two. Consider adding a small example. - -## Support us - -[](https://spatie.be/github-ad-click/filament-api-service) - -We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us). - -We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards). ## Installation @@ -23,43 +13,46 @@ You can install the package via composer: composer require rupadana/filament-api-service ``` -You can publish and run the migrations with: - -```bash -php artisan vendor:publish --tag="filament-api-service-migrations" -php artisan migrate -``` - -You can publish the config file with: +## Usage ```bash -php artisan vendor:publish --tag="filament-api-service-config" +php artisan make:filament-api-service BlogResource ``` -This is the contents of the published config file: +Add this code to your routes file, example in routes/api.php ```php -return [ -]; +... +use App\Filament\Resources\BlogResource\Api; +... + +BlogApiService::routes(); ``` -Optionally, you can publish the views using +and then you will got this routes; -```bash -php artisan vendor:publish --tag="filament-api-service-views" -``` +| Route | Description | +----------------------- +| '/api/blogs' | This will return LengthAwarePaginator | +| '/api/blogs/1' | This will return single resource | -## Usage -```php -$filamentApiService = new Rupadana\FilamentApiService(); -echo $filamentApiService->echoPhrase('Hello, Rupadana!'); -``` +Im using `"spatie/laravel-query-builder": "^5.3"` to handle query and filtering. u can see `"spatie/laravel-query-builder": "^5.3"` [https://spatie.be/docs/laravel-query-builder/v5/introduction](documentation) -## Testing -```bash -composer test +You can specified `allowedFilters` and `allowedFields` in your model + +Example +```php +class User extends Model { + public static array $allowedFilters = [ + 'name' + ]; + + public static array $allowedFields = [ + 'name' + ]; +} ``` ## Changelog