Skip to content

Commit

Permalink
fixed docs
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiasFranek committed Feb 23, 2017
1 parent 3cfcb53 commit a9e2d92
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 14 deletions.
29 changes: 21 additions & 8 deletions docs/BasicUsage/BasicUsage.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,39 +132,50 @@ $query->get('Students')->findAll();
if you call this method you get all Students in this case

```php
$query->get('Students')->findBy(['first_name' => 'seppi']);
$query->get('Students')->findBy(['firstName' => 'seppi']);
```
this method return all the students with the first name 'seppi'

you also can search recursively like this:

```php
$query->get('Period')->findBy(['teacher:first_name' => 'seppi']);
$query->get('Period')->findBy(['teachers:firstName' => 'seppi']);
```
this will return all the Period Models where the teachers have the first name 'seppi'

you also can search if a certain string exists in a firstName like this:

```php
$query->get('Period')->findBy(['teacher:first_name' => '%epp%']);
$query->get('Period')->findBy(['teachers:firstName' => '%epp%']);
```
you also can compare dates also:

```php
$query->get('Period')->findBy(['startDate' => '<Y-m-d']);
```
the < is how you want to compare the date < for <= and > for >=:
possible formats:
* Y-m-d H:i
* Y-m-d
you also can sort the given output
```php
$query->get('Exams')->findAll(['start_date' => 'ASC|DESC']);
$query->get('Exams')->findAll(['startDate' => 'ASC|DESC']);
//you can sort by properties that are in objects that the main objects contains, but that is restricted to one level
$query->get('Exams')->findAll(['teachers:first_name' => 'ASC|DESC']);
$query->get('Exams')->findAll(['teachers:firstName' => 'ASC|DESC']);
```
this will either order the model descending (DESC) or ascending (ASC)
you also can now give a limit to the query
```php
$query->get('Exams')->findAll(['start_date' => 'ASC|DESC'], 5);
$query->get('Exams')->findAll(['startDate' => 'ASC|DESC'], 5);
```
### Custom Repositories
Expand All @@ -173,12 +184,12 @@ There are two custom Repositories in the core already and they are the
* PeriodRepository only has some additional parameters to the standard methods.
* SubstitutionsRepository has some additional MANDATORY parameters to the standard methods.

```php
//department is not mandatory
$query->get('Substitution')->findAll(department, startDate, endDate);
```

* UserRepository with these additional functions (This Repository can only execute these functions):
```php
Expand Down Expand Up @@ -229,3 +240,5 @@ $students = \Webuntis\Serializer\Serializer::serialize($students, 'json|xml|yml
```
23 changes: 17 additions & 6 deletions docs/BasicUsage/Querys.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,39 +24,50 @@ $query->get('Students')->findAll();
if you call this method you get all Students in this case

```php
$query->get('Students')->findBy(['first_name' => 'seppi']);
$query->get('Students')->findBy(['firstName' => 'seppi']);
```
this method return all the students with the first name 'seppi'

you also can search recursively like this:

```php
$query->get('Period')->findBy(['teacher:first_name' => 'seppi']);
$query->get('Period')->findBy(['teachers:firstName' => 'seppi']);
```
this will return all the Period Models where the teachers have the first name 'seppi'

you also can search if a certain string exists in a firstName like this:

```php
$query->get('Period')->findBy(['teacher:first_name' => '%epp%']);
$query->get('Period')->findBy(['teachers:firstName' => '%epp%']);
```
you also can compare dates also:

```php
$query->get('Period')->findBy(['startDate' => '<Y-m-d']);
```
the < is how you want to compare the date < for <= and > for >=:
possible formats:
* Y-m-d H:i
* Y-m-d
you also can sort the given output
```php
$query->get('Exams')->findAll(['start_date' => 'ASC|DESC']);
$query->get('Exams')->findAll(['startDate' => 'ASC|DESC']);
//you can sort by properties that are in objects that the main objects contains, but that is restricted to one level
$query->get('Exams')->findAll(['teachers:first_name' => 'ASC|DESC']);
$query->get('Exams')->findAll(['teachers:firstName' => 'ASC|DESC']);
```
this will either order the model descending (DESC) or ascending (ASC)
you also can now give a limit to the query
```php
$query->get('Exams')->findAll(['start_date' => 'ASC|DESC'], 5);
$query->get('Exams')->findAll(['startDate' => 'ASC|DESC'], 5);
```
### Custom Repositories
Expand Down

0 comments on commit a9e2d92

Please sign in to comment.