Skip to content

Commit

Permalink
Added configurations docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
gent-fella-health committed Nov 4, 2020
1 parent dd0f124 commit 837dad6
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/_sidebar.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
- Getting started
- [Quick start](README.md)
- [Installation](installation.md)
- [Configuration](configuration.md)

- Selecting fields
- [Quick start](selecting_fields.md?id=selecting-fields)
Expand Down
64 changes: 64 additions & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
## Configuration

> [Check how to use in real application.](https://github.com/gentritabazi01/Clean-Laravel-Api)
1. Extends `one2tek\larapi\Controllers\LaravelController` in your base controller.

```php
<?php
use one2tek\larapi\Controllers\LaravelController;

class Controller extends LaravelController {
// ...
}
```

2. Extends `one2tek\larapi\Database\Repository` in your base repository.

```php
<?php
use one2tek\larapi\Database\Repository as BaseRepository;

abstract class Repository extends BaseRepository {
// ...
}
```

3. Example Controller or Service for Users.

```php
<?php
use App\Http\Repositories\UserRepository;

class UsersController extends Controller
{
private $userRepository;

public function __construct(UserRepository $userRepository)
{
$this—>userRepository = $userRepository;
}

public function getAll()
{
$resourceOptions = $this—>parseResourceOptions();

$users = $this—>userRepository—>get($resourceOptions);

return $this—>response($users);
}
}
```

4. Example Repository for Users.

```php
<?php
class UserRepository extends Repository
{
public function getModel()
{
return new User();
}
}
```

0 comments on commit 837dad6

Please sign in to comment.