Skip to content

Commit c9027c3

Browse files
committed
Update readme
1 parent 0b6df53 commit c9027c3

File tree

1 file changed

+61
-29
lines changed

1 file changed

+61
-29
lines changed

README.md

Lines changed: 61 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,42 @@
55
[![GitHub Code Style Action Status](https://img.shields.io/github/actions/workflow/status/naimsolong/laravel-data-extractor/fix-php-code-style-issues.yml?branch=main&label=code%20style&style=flat-square)](https://github.com/naimsolong/laravel-data-extractor/actions?query=workflow%3A"Fix+PHP+code+style+issues"+branch%3Amain)
66
[![Total Downloads](https://img.shields.io/packagist/dt/naimsolong/laravel-data-extractor.svg?style=flat-square)](https://packagist.org/packages/naimsolong/laravel-data-extractor)
77

8-
This is where your description should go. Limit it to a paragraph or two. Consider adding a small example.
8+
A Laravel package for extracting data from Eloquent models and their relationships with flexible configuration options. This package provides a simple and intuitive way to extract structured data from your models, making it perfect for API responses, data exports, or any scenario where you need to transform model data into a specific format.
99

10-
## Support us
10+
## What It Does
1111

12-
[<img src="https://github-ads.s3.eu-central-1.amazonaws.com/data-extractor.jpg?t=1" width="419px" />](https://spatie.be/github-ad-click/data-extractor)
12+
The extractor leverages Laravel's relationship system to automatically include related data based on your configuration, while providing fine-grained control over which fields are included or excluded from the extraction process.
1313

14-
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).
14+
You can use the available options inside config file:
1515

16-
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).
16+
```php
17+
use NaimSolong\DataExtractor\Extract;
18+
19+
// Option
20+
(new Extract)
21+
->option('User')
22+
->queryId(4)
23+
->toSql();
24+
25+
// Source
26+
(new Extract)
27+
->source('session')
28+
->queryId(3)
29+
->toSql();
30+
```
31+
32+
Or you can use model that you have queried:
33+
34+
```php
35+
use NaimSolong\DataExtractor\Extract;
36+
use App\Models\User;
37+
38+
// Extract directly
39+
(new Extract)
40+
->toSql(
41+
User::get()
42+
);
43+
```
1744

1845
## Installation
1946

@@ -23,13 +50,6 @@ You can install the package via composer:
2350
composer require naimsolong/laravel-data-extractor
2451
```
2552

26-
You can publish and run the migrations with:
27-
28-
```bash
29-
php artisan vendor:publish --tag="data-extractor-migrations"
30-
php artisan migrate
31-
```
32-
3353
You can publish the config file with:
3454

3555
```bash
@@ -40,22 +60,38 @@ This is the contents of the published config file:
4060

4161
```php
4262
return [
63+
'is_enabled' => env('DATA_EXTRACTOR_ENABLED', false),
64+
65+
'options' => [
66+
[
67+
'name' => 'Default',
68+
'description' => 'Extra all user data',
69+
'format' => 'sql',
70+
'source' => 'default',
71+
'export' => 'default',
72+
],
73+
],
74+
75+
'source' => [
76+
'default' => [
77+
'connection' => 'mysql',
78+
'model' => User::class,
79+
'relationships' => [
80+
'mainProfile',
81+
],
82+
],
83+
],
84+
85+
'export' => [
86+
'default' => [
87+
'file_name' => 'data-extractor',
88+
'file_path' => 'data-extractor',
89+
'disk' => 'local',
90+
],
91+
],
4392
];
4493
```
4594

46-
Optionally, you can publish the views using
47-
48-
```bash
49-
php artisan vendor:publish --tag="data-extractor-views"
50-
```
51-
52-
## Usage
53-
54-
```php
55-
$dataExtractor = new NaimSolong\DataExtractor();
56-
echo $dataExtractor->echoPhrase('Hello, naimsolong!');
57-
```
58-
5995
## Testing
6096

6197
```bash
@@ -70,10 +106,6 @@ Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed re
70106

71107
Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
72108

73-
## Security Vulnerabilities
74-
75-
Please review [our security policy](../../security/policy) on how to report security vulnerabilities.
76-
77109
## Credits
78110

79111
- [Amirul Naim](https://github.com/naimsolong)

0 commit comments

Comments
 (0)