-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dd0f124
commit 837dad6
Showing
2 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} | ||
``` |