Skip to content

Commit

Permalink
#7 WIP doc
Browse files Browse the repository at this point in the history
  • Loading branch information
dimitriBouteille committed Jan 20, 2024
1 parent 21c22ce commit fa69875
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Simply put, wp-orm is a library that makes it easy to manipulate a WordPress dat

- The `wpdb` connection is used so **no configuration is needed to use**
- Ability to [create models](doc/documentation.md#model) simply
- WordPress works with custom content types, you can simply [use the default types of WordPress](doc/documentation.md#use-wordpress-models) (page, attachment, ...) and create [custom models](doc/documentation.md#create-model)
- WordPress works with custom content types, you can simply [use the default types of WordPress](doc/documentation.md#use-wordpress-models) (page, attachment, ...) and create [custom models for your types](doc/documentation.md#custom-post-type-model) or create [custom model](doc/documentation.md)
- Ability to [filter data](doc/documentation.md#filter-data) easily via taps
- All the features available in Eloquent, are usable with this library

Expand Down
25 changes: 25 additions & 0 deletions doc/available-filters.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Available filters

## Post

**Available for all post models**

- `Dbout\WpOrm\Taps\Post\IsAuthorTap`
- `Dbout\WpOrm\Taps\Post\IsPingStatusTap`
- `Dbout\WpOrm\Taps\Post\IsPostTypeTap`
- `Dbout\WpOrm\Taps\Post\IsStatusTap`

**Attachment CPT**

- `Dbout\WpOrm\Taps\Attachment\IsMimeTypeTap`

## Comment

- `Dbout\WpOrm\Taps\Comment\IsApprovedTap`
- `Dbout\WpOrm\Taps\Comment\IsCommentTypeTap`
- `Dbout\WpOrm\Taps\Comment\IsUserTap`

## Option

- `Dbout\WpOrm\Taps\Option\IsAutoloadTap`

31 changes: 31 additions & 0 deletions doc/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,37 @@

## Filter data

You can easily filter data via the `tap` function :

```php
use Dbout\WpOrm\Taps\Post\IsAuthorTap;
use Dbout\WpOrm\Taps\Post\IsStatusTap;
use Dbout\WpOrm\Enums\PostStatus;
use Dbout\WpOrm\Models\Post;

$posts = Post::query()
->tap(new IsAuthorTap(1))
->get();
```

This query, returns all user posts with ID 1.

If you want to apply multiple filters, nothing complicated :

```php
use Dbout\WpOrm\Taps\Post\IsAuthorTap;
use Dbout\WpOrm\Taps\Post\IsStatusTap;
use Dbout\WpOrm\Enums\PostStatus;
use Dbout\WpOrm\Models\Post;

$posts = Post::query()
->tap(new IsAuthorTap(1))
->tap(new IsStatusTap(PostStatus::Publish))
->get();
```

You can find all the available filters here: [Available filters](available-filters.md).

## Create Model

### Model
Expand Down

0 comments on commit fa69875

Please sign in to comment.