Skip to content

Commit

Permalink
docs: update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
SiavashBamshadnia committed Jan 30, 2024
1 parent 3dcedf6 commit 007ae6b
Show file tree
Hide file tree
Showing 7 changed files with 125 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/QE/Advanced/case.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Case
# case

The case expression is a powerful tool that allows you to handle multiple conditions in your code, similar to an
if-then-else statement in standard programming languages.
Expand Down
11 changes: 11 additions & 0 deletions docs/QE/Advanced/exists.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,15 @@ $queryResult = Author::select(
Book::where('books.author_id', c('authors.id'))
)->as('has_book')
)->get();
```

```php
$suppliers = DB::table('suppliers')->select(
'id',
'name',
)->whereRaw(
QE::exists(
Db::table('products')->where('products.supplier_id', c('suppliers.id'))->where('price', '<', 25)
)
)->toSql();
```
13 changes: 11 additions & 2 deletions docs/QE/Advanced/isNull.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ use function sbamtr\LaravelQueryEnrich\c;
$books = Book::select(
'id',
'name',
QE::isNull(c('description'))->as('is_null')
QE::isNull(c('description'))->as('is_description_null')
)->get();
```
```

```php
use sbamtr\LaravelQueryEnrich\QE;
use function sbamtr\LaravelQueryEnrich\c;

$books = DB::table('books')->whereRaw(
QE::isNull(c('description'))
)->get();
```
28 changes: 28 additions & 0 deletions docs/QE/String/contains.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# contains

The `contains` function checks if a provided string contains a specified substring. To use it, you pass two
parameters: `$haystack` (the full string) and `$needle` (the substring you're looking for). The method then returns a
Boolean, letting you know if the string contains the specified substring.

## Example Usage

```php
use sbamtr\LaravelQueryEnrich\QE;
use function sbamtr\LaravelQueryEnrich\c;

$people = People::select(
'id',
'first_name',
'last_name',
QE::startsWith(c('first_name'), 'A')->as('is_first_name_starting_with_a')
)->get();
```

```php
use sbamtr\LaravelQueryEnrich\QE;
use function sbamtr\LaravelQueryEnrich\c;

$people = People::whereRaw(
QE::startsWith(c('first_name'), 'Walt')
)->get();
```
28 changes: 28 additions & 0 deletions docs/QE/String/endsWith.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# endsWith

The `endsWith` function checks if a provided string ends with a specified substring. To use it, you pass two
parameters: `$haystack` (the full string) and `$needle` (the substring you're looking for). The method then returns a
Boolean, letting you know if the string ends with the specified substring.

## Example Usage

```php
use sbamtr\LaravelQueryEnrich\QE;
use function sbamtr\LaravelQueryEnrich\c;

$people = People::select(
'id',
'first_name',
'last_name',
QE::endsWith(c('first_name'), 'Junior')->as('is_first_name_ending_with_junior'))
)->get();
```

```php
use sbamtr\LaravelQueryEnrich\QE;
use function sbamtr\LaravelQueryEnrich\c;

$people = People::whereRaw(
QE::endsWith(c('first_name'), 'Junior')
)->get();
```
18 changes: 18 additions & 0 deletions docs/QE/String/md5.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# md5

The `md5` method, belonging to the Advanced namespace, is a static function to calculate the MD5 hash for a given
parameter.

## Example Usage

```php
use sbamtr\LaravelQueryEnrich\QE;
use function sbamtr\LaravelQueryEnrich\c;

$books = Book::select(
'id',
'name',
'price',
QE::md5(QE::concatWS(',', c('name', 'price')))->as('checksum')
)->get();
```
28 changes: 28 additions & 0 deletions docs/QE/String/startsWith.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# startsWith

The `startsWith` function checks if a provided string starts with a specified substring. To use it, you pass two
parameters: `$haystack` (the full string) and `$needle` (the substring you're looking for). The method then returns a
Boolean, letting you know if the string starts with the specified substring.

## Example Usage

```php
use sbamtr\LaravelQueryEnrich\QE;
use function sbamtr\LaravelQueryEnrich\c;

$people = People::select(
'id',
'first_name',
'last_name',
QE::startsWith(c('first_name'), 'A')->as('is_first_name_starting_with_a')
)->get();
```

```php
use sbamtr\LaravelQueryEnrich\QE;
use function sbamtr\LaravelQueryEnrich\c;

$people = People::whereRaw(
QE::startsWith(c('first_name'), 'Walt')
)->get();
```

0 comments on commit 007ae6b

Please sign in to comment.