定制 alexwenzel/cmsbasics 二次开发

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

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

alexwenzel/cmsbasics

Composer 安装命令:

composer require alexwenzel/cmsbasics

包简介

A package for Laravel, which I use to build repetitive resource Items.

README 文档

README

A package for Laravel, which I use to build repetitive resource Items.

Model

Create a model for your new resource item.

The resource model should have a static $rules property, which contain all resource rules.

class Post extends \Eloquent {

  protected $table = 'posts';
  protected $fillable = ['title', 'body'];

  public static $rules = [
    'title' => 'required',
    'body' => 'required',
  ];
}

Controller

Create a new controller by extending the base resource controller. In the constructor you can specify some settings.

  • dependency => your resource item's model
  • resource_name => the identifier of your resource, the one you use at Route::resource()
  • view_dir => path to the rescource views
use Alexwenzel\Cmsbasics\Controllers\Resource;

class PostsController extends Resource {

  public function __construct(Post $model)
  {
    parent::__construct([
      'dependency'    => $model,
      'resource_name' => 'posts',
      'view_dir'      => 'path.to.views',
    ]);
  }
}

Then register the controller in your routes.

Route::resource('posts', 'PostsController');

Customize behaviour

You cann customize the behaviour of the base resource controller by overriding specific methods

protected function _index_items()
protected function _store_data()
protected function _store_validator($data)
protected function _store_fails($data, $validator)
protected function _store_finished($data, $model)
protected function _update_data()
protected function _update_validator($id, $data)
protected function _update_fails($data, $model, $validator)
protected function _update_finished($data, $model)
protected function _destroy_finished()

Events

The following Events are fired within the base resource controller:

index

[resource_name].index

create

[resource_name].create

store

[resource_name].store

Passes the newly created resource as the first argument.

show

[resource_name].show

Passes the requested resource as the first argument.

edit

[resource_name].edit

Passes the requested resource as the first argument.

update

[resource_name].update

Passes the updated resource as the first argument.

destroy

[resource_name].destroy

View

This package comes with default views for all actions (index, create, show, edit). Publish the package views as a starting point.

php artisan view:publish alexwenzel/cmsbasics

Copy the package views to a new folder and customize them.

class PostsController extends Resource {

  public function __construct(Post $model)
  {
    parent::__construct([
      'dependency'    => $model,
      'resource_name' => 'posts',
      'view_dir'      => 'path.to.views',
    ]);
  }
}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Unknown
  • 更新时间: 2014-07-29

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固