定制 leandrowkz/laravel-basis 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

leandrowkz/laravel-basis

Composer 安装命令:

composer create-project leandrowkz/laravel-basis

包简介

Laravel Basis is a package that provides a base service layer to your application, containing CRUD operations.

README 文档

README

Build Status Latest Stable Version License

Laravel Basis is a package that provides a base CRUD layer for your application.

Laravel Basis

  • Leandrowkz\Basis\Controllers\BaseController
  • Leandrowkz\Basis\Services\BaseService
  • Leandrowkz\Basis\Traits\AccessibleProps
  • Leandrowkz\Basis\Traits\MutatesProps

These classes provides an easy way to CRUD operations inside Laravel apps. All you have to do is to extend and configure your classes from those available here.

Leandrowkz\Basis\Controllers\BaseController

Every class extended from BaseController must set the $service and $request (for validation) class names strings (Ex: FooService::class).

protected $service;
protected $request;
public function all();
public function find(string $id);
public function create(array $data);
public function update(string $id, array $data);
public function delete(string $id);
public function exists($id);
public function validate();
public function service(BaseServiceInterface $service = null);

Leandrowkz\Basis\Service\BaseService

Every class exteded from BaseService must set $model class name string (Ex: FooModel::class). The create/update operations are done by using de $fillable array presented on $model class.

protected $model;
public function all();
public function find(string $id);
public function query($where);
public function create(array $data);
public function update(string $id, array $data);
public function delete(string $id);
public function model(string $model = null);

Leandrowkz\Basis\Traits\AccessibleProps

This trait adds to the target class fluent getters/setters to access any property through a method with same name. As a caveat it breaks any property visibility.

protected $foo = 1;
protected $bar = 2;
$this->foo(); // returns 1;
$this->bar(); // returns 2;
$this->foo(3); // sets $this->foo as 3;
$this->bar(3); // sets $this->bar as 3;

Leandrowkz\Basis\Traits\MutatesProps

This trait adds a method that fetch all class properties and transforms all props with valid class names into objects of same class. Ex:

protected $customService = MyService::class; // string
$this->customService; // string
$this->mutateProps();
$this->customService; // MyService object

License

This code is published under the MIT License. This means you can do almost anything with it, as long as the copyright notice and the accompanying license file is left intact.

Contributing

Feel free to send pull requests or create issues if you come across problems or have great ideas. Any input is appreciated!

统计信息

  • 总下载量: 748
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-06-07

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固