chhw/commander
This package gives you to automatically generate service/repository class, which is extended by Laravel original make commands.
800
1
| Install | |
|---|---|
composer require chhw/commander |
|
| Latest Version: | 2.1.0 |
| PHP: | >=5.4 |
| License: | MIT |
| Last Updated: | Dec 2, 2021 |
| Links: | GitHub · Packagist |
Maintainer: wangchristine
Laravel Commander
This package extends Laravel generating commands.
Installation
Install by composer
$ composer require chhw/commander
If you are under Laravel 5.5, please add this code in config/app.php below.
<?php
'providers' => [
CHHW\Commander\CommanderServiceProvider::class,
],
?>
Also support Lumen now!!
In bootstrap/app.php, you should:
- uncomment
$app->withEloquent(); - add
$app->register(CHHW\Commander\CommanderServiceProvider::class);
And add config/database.php just like Laravel.
Usage
Generate Service:
Create a new service class.
$ php artisan make:service UserService
Generate Repository:
Create a new repository class.
$ php artisan make:repository UserRepository
Or you can create a new repository class with
--model=
$ php artisan make:repository UserRepository --model=User
Supported methods
You can use these methods in service:
- all($columns = ['*'])
- find($id, $columns = ['*'])
- firstOrFail($columns = ['*'])
- get($columns = ['*'])
- create(array $attributes = [])
- with($relations)
- destroy($ids)
- paginate($perPage = null, $columns = ['*'], $pageName = 'page', $page = null)
- simplePaginate($perPage = null, $columns = ['*'], $pageName = 'page', $page = null)
Example:
app/Services/UserService.php
protected $userRepository;
public function __construct(UserRepository $repository)
{
$this->userRepository = $repository;
}
public function getAll()
{
return $this->userRepository->all();
}
Related Packages
alejojperez/laravel-skeleton-generator
A package containing a set of commands to generate any kind of component
22
1
jakubkratina/lumen-dingo-route-list
Route:list command support at Lumen framework application with Dingo API framewo...
30,806
3
Version History
| Version | Released | PHP | Laravel | License |
|---|---|---|---|---|
| 2.1.0 | >=5.4 | >=5.0 | MIT | |
| 2.0.9 | >=5.4 | >=5.0 | MIT | |
| 2.0.8 | >=5.4 | ^5.0| | MIT | |
| 2.0.7 | >=5.4 | ^5.0| | MIT | |
| 2.0.6 | ^5.4 | ^5.0| | MIT | |
| 2.0.5 | ^7.0.0 | ^5.0| | MIT | |
| 2.0.4 | ^7.0.0 | ^5.0| | MIT | |
| 2.0.3 | ^7.0.0 | ^5.0 | MIT | |
| 2.0.2 | ^7.0.0 | ^5.0 | MIT | |
| 2.0.1 | ^7.0.0 | ^5.0 | MIT | |
| 2.0.0 | ^7.0.0 | ^5.0 | MIT | |
| 1.0.2 | ^7.0.0 | ^5.0 | MIT | |
| 1.0.1 | ^7.0.0 | ^5.0 | MIT | |
| 1.0.0 | ^7.0.0 | ^5.0 | MIT |