Skip to content

Commit b78f6a0

Browse files
committed
Query and Flag features added to the readme
1 parent ad3fe6e commit b78f6a0

File tree

1 file changed

+61
-9
lines changed

1 file changed

+61
-9
lines changed

README.md

Lines changed: 61 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@ Laravel IMAP is an easy way to integrate the native php imap library into your *
1818
- [Client::class](#clientclass)
1919
- [Message::class](#messageclass)
2020
- [Folder::class](#folderclass)
21+
- [Query::class](#queryclass)
2122
- [Attachment::class](#attachmentclass)
2223
- [MessageCollection::class](#messagecollectionclass)
2324
- [AttachmentCollection::class](#attachmentcollectionclass)
2425
- [FolderCollection::class](#foldercollectionclass)
26+
- [FlaggCollection::class](#flaggcollectionclass)
2527
- [Known issues](#known-issues)
2628
- [Milestones & upcoming features](#milestones--upcoming-features)
2729
- [Security](#security)
@@ -178,15 +180,19 @@ Search for specific emails:
178180

179181
//Get all messages since march 15 2018
180182
/** @var \Webklex\IMAP\Support\MessageCollection $aMessage */
181-
$aMessage = $oFolder->searchMessages([['SINCE', Carbon::parse('15.03.2018')]]);
183+
$aMessage = $oFolder->query()->whereSince('15.03.2018')->get();
182184

183185
//Get all messages containing "hello world"
184186
/** @var \Webklex\IMAP\Support\MessageCollection $aMessage */
185-
$aMessage = $oFolder->searchMessages([['TEXT', 'hello world']]);
187+
$aMessage = $oFolder->query()->whereText('hello world')->get();
186188

187189
//Get all unseen messages containing "hello world"
188190
/** @var \Webklex\IMAP\Support\MessageCollection $aMessage */
189-
$aMessage = $oFolder->searchMessages([['UNSEEN'], ['TEXT', 'hello world']]);
191+
$aMessage = $oFolder->query()->whereUnseen()->whereText('hello world')->get();
192+
193+
//Extended custom search query for all messages containing "hello world" and have been received since march 15 2018
194+
/** @var \Webklex\IMAP\Support\MessageCollection $aMessage */
195+
$aMessage = $oFolder->query()->where([['TEXT', 'Hello world'], ['SINCE', \Carbon::parse('15.03.2018')]])->get();
190196
```
191197

192198
Available search criteria:
@@ -262,21 +268,21 @@ Fetch messages without body fetching (decrease load):
262268
/** @var \Webklex\IMAP\Folder $oFolder */
263269

264270
/** @var \Webklex\IMAP\Support\MessageCollection $aMessage */
265-
$aMessage = $oFolder->searchMessages([['TEXT', 'Hello world']], null, false);
271+
$aMessage = $oFolder->query()->whereText('Hello world')->setFetchBody(false)->get();
266272

267273
/** @var \Webklex\IMAP\Support\MessageCollection $aMessage */
268-
$aMessage = $oFolder->getMessages('ALL', null, false);
274+
$aMessage = $oFolder->query()->whereAll()->setFetchBody(false)->setFetchAttachment();
269275
```
270276

271277
Fetch messages without body and attachment fetching (decrease load):
272278
``` php
273279
/** @var \Webklex\IMAP\Folder $oFolder */
274280

275281
/** @var \Webklex\IMAP\Support\MessageCollection $aMessage */
276-
$aMessage = $oFolder->searchMessages([['TEXT', 'Hello world']], null, false, 'UTF-8', false);
282+
$aMessage = $oFolder->query()->whereText('Hello world')->setFetchBody(false)->setFetchAttachment(false)->get();
277283

278284
/** @var \Webklex\IMAP\Support\MessageCollection $aMessage */
279-
$aMessage = $oFolder->getMessages('ALL', null, false, false);
285+
$aMessage = $oFolder->query()->whereAll()->setFetchBody(false)->setFetchAttachment(false)->get();
280286
```
281287

282288
Find the folder containing a message:
@@ -353,7 +359,7 @@ $oFolder = $aMessage->getContainingFolder();
353359
| getSender | | array | Get the current sender information |
354360
| getBodies | | mixed | Get the current bodies |
355361
| getRawBody | | mixed | Get the current raw message body |
356-
| getFlags | | array | Get the current message flags |
362+
| getFlags | | FlagCollection | Get the current message flags |
357363
| is | | boolean | Does this message match another one? |
358364

359365
### [Folder::class](src/IMAP/Folder.php)
@@ -370,7 +376,46 @@ $oFolder = $aMessage->getContainingFolder();
370376
| getStatus | integer $options | object | Returns status information on a mailbox |
371377
| appendMessage | string $message, string $options, string $internal_date | bool | Append a string message to the current mailbox |
372378
| getClient | | Client | Get the current Client instance |
373-
379+
| query | string $charset = 'UTF-8' | WhereQuery | Get the current Client instance |
380+
381+
### [Query::class](src/IMAP/WhereQuery.php)
382+
| Method | Arguments | Return | Description |
383+
| ------------------ | --------------------------------- | :---------------: | ---------------------------------------------- |
384+
| where | mixed $criteria, $value = null | WhereQuery | Add new criteria to the current query |
385+
| orWhere | Closure $$closure | WhereQuery | If supported you can perform extended search requests |
386+
| andWhere | Closure $$closure | WhereQuery | If supported you can perform extended search requests |
387+
| whereAll | | WhereQuery | Select all available messages |
388+
| whereAnswered | | WhereQuery | Select answered messages |
389+
| whereAnswered | | WhereQuery | Select answered messages |
390+
| whereDeleted | | WhereQuery | Select deleted messages |
391+
| whereNew | | WhereQuery | Select new messages |
392+
| whereOld | | WhereQuery | Select old messages |
393+
| whereRecent | | WhereQuery | Select recent messages |
394+
| whereSeen | | WhereQuery | Select seen messages |
395+
| whereUnanswered | | WhereQuery | Select unanswered messages |
396+
| whereUndeleted | | WhereQuery | Select undeleted messages |
397+
| whereUnflagged | | WhereQuery | Select unflagged messages |
398+
| whereUnseen | | WhereQuery | Select unseen messages |
399+
| whereUnkeyword | string $value | WhereQuery | Select messages matching a given unkeyword |
400+
| whereTo | string $value | WhereQuery | Select messages matching a given receiver (To:) |
401+
| whereText | string $value | WhereQuery | Select messages matching a given text body |
402+
| whereSubject | string $value | WhereQuery | Select messages matching a given subject |
403+
| whereSince | string $value | WhereQuery | Select messages since a given date |
404+
| whereOn | string $value | WhereQuery | Select messages on a given date |
405+
| whereKeyword | string $value | WhereQuery | Select messages matching a given keyword |
406+
| whereFrom | string $value | WhereQuery | Select messages matching a given sender (From:) |
407+
| whereFlagged | string $value | WhereQuery | Select messages matching a given flag |
408+
| whereCc | string $value | WhereQuery | Select messages matching a given receiver (CC:) |
409+
| whereBody | string $value | WhereQuery | Select messages matching a given HTML body |
410+
| whereBefore | string $value | WhereQuery | Select messages before a given date |
411+
| whereBcc | string $value | WhereQuery | Select messages matching a given receiver (BCC:) |
412+
| get | | MessageCollection | Fetch messages with the current query |
413+
| limit | integer $limit, integer $page = 1 | WhereQuery | Limit the amount of messages being fetched |
414+
| setFetchOptions | boolean $fetch_options | WhereQuery | Set the fetch options |
415+
| setFetchBody | boolean $fetch_body | WhereQuery | Set the fetch body option |
416+
| getFetchAttachment | boolean $fetch_attachment | WhereQuery | Set the fetch attachment option |
417+
| setFetchFlags | boolean $fetch_flags | WhereQuery | Set the fetch flags option |
418+
374419
### [Attachment::class](src/IMAP/Attachment.php)
375420
| Method | Arguments | Return | Description |
376421
| -------------- | ------------------------------ | :------------: | ------------------------------------------------------ |
@@ -391,6 +436,13 @@ Extends [Illuminate\Support\Collection::class](https://laravel.com/api/5.4/Illum
391436
| -------- | --------------------------------------------------- | :------------------: | -------------------------------- |
392437
| paginate | int $perPage = 15, $page = null, $pageName = 'page' | LengthAwarePaginator | Paginate the current collection. |
393438

439+
### [FlaggCollection::class](src/IMAP/Support/FlaggCollection.php)
440+
Extends [Illuminate\Support\Collection::class](https://laravel.com/api/5.4/Illuminate/Support/Collection.html)
441+
442+
| Method | Arguments | Return | Description |
443+
| -------- | --------------------------------------------------- | :------------------: | -------------------------------- |
444+
| paginate | int $perPage = 15, $page = null, $pageName = 'page' | LengthAwarePaginator | Paginate the current collection. |
445+
394446
### [AttachmentCollection::class](src/IMAP/Support/AttachmentCollection.php)
395447
Extends [Illuminate\Support\Collection::class](https://laravel.com/api/5.4/Illuminate/Support/Collection.html)
396448

0 commit comments

Comments
 (0)