codewiser/laravel-make
最新稳定版本:v1.1.1
Composer 安装命令:
composer require codewiser/laravel-make
包简介
Provide Laravel make:builder and make:collection commands
README 文档
README
Make Collection
Run command.
php artisan make:collection UserCollection
It will create Collection class.
namespace App\Collections; use App\Models\User as Model; use Illuminate\Database\Eloquent\Collection; /** * @method Model first(callable $callback = null, $default = null) * @method Model firstOrFail($key = null, $operator = null, $value = null) * @method Model firstWhere($key, $operator = null, $value = null) * @method Model find($key, $default = null) * @method Model last(callable $callback = null, $default = null) * @method Model sole($key = null, $operator = null, $value = null) */ class UserCollection extends Collection { // }
Register it to a model.
namespace App\Models; use App\Collections\UserCollection; use Illuminate\Database\Eloquent\Model; /** * @method static UserCollection all($columns = ['*']) */ class User extends Model { public function newCollection(array $models = []): UserCollection { return new UserCollection($models); } }
Make Builder
Run command.
php artisan make:builder UserBuilder
It will create Builder class.
namespace App\Builders; use App\Models\User as Model; use Closure; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Collection; /** * @method Model getModel() * @method Model make(array $attributes = []) * @method Model create(array $attributes = []) * @method Model forceCreate(array $attributes) * @method Model sole($columns = ['*']) * @method Model find($id, $columns = ['*']) * @method Model findOr($id, $columns = ['*'], Closure $callback = null) * @method Model findOrNew($id, $columns = ['*']) * @method Model findOrFail($id, $columns = ['*']) * @method Model first($columns = ['*']) * @method Model firstOr($columns = ['*'], Closure $callback = null) * @method Model firstOrNew(array $attributes = [], array $values = []) * @method Model firstOrFail($columns = ['*']) * @method Model firstOrCreate(array $attributes = [], array $values = []) * @method Model firstWhere($column, $operator = null, $value = null, $boolean = 'and') * @method Model updateOrCreate(array $attributes, array $values = []) * * @method UserCollection|Model[] findMany($ids, $columns = ['*']) * @method UserCollection|Model[] get($columns = ['*']) */ class UserBuilder extends Builder { // }
Register it to a model.
namespace App\Models; use App\Builders\UserBuilder; use Illuminate\Database\Eloquent\Model; /** * @method static UserBuilder query() */ class User extends Model { public function newEloquentBuilder($query): UserBuilder { return new UserBuilder($query); } }
统计信息
- 总下载量: 419
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-08-11