jan-dolata/crude-crud

为Laravel提供的简略CRUD

v1.1.27 2017-03-28 13:05 UTC

README

Latest Version on Packagist Software License Build Status Coverage Status Quality Score Total Downloads

完整文档

目录表

安装

通过Composer

$ composer require jan-dolata/crude-crud

将ServiceProvider添加到config/app

JanDolata\CrudeCRUD\CrudeCRUDServiceProvider::class

发布和迁移

$ php artisan vendor:publish --provider="JanDolata\CrudeCRUD\CrudeCRUDServiceProvider"
$ php artisan migrate

检查配置文件config/crude.php

使用方法

创建目录app/Engine/Crude

在app/Engine/Crude目录中创建用于列表的类

<?php

namespace App\Engine\Crude;

use Crude;
use CrudeListInterface;
use CrudeFromModelTrait;

class ListName extends Crude implements
    CrudeListInterface
{

    use CrudeFromModelTrait;

    public function __construct()
    {
        $this->setModel(new \App\Engine\Models\ModelName);

        $this->prepareCrudeSetup();
    }

}

在控制器操作中

return view('viewName', [
    'crudeSetup' => [(new \App\Engine\Crude\ListName)->getCrudeSetupData()]
]);

在视图中

@include('CrudeCRUD::start')

它正常工作。

=============

示例

创建书籍表迁移的一部分

    public function up()
    {
        Schema::create('books', function (Blueprint $table) {
            $table->increments('id');
            $table->string('tile');
            $table->integer('order');
            $table->timestamps();
        });
    }
namespace App\Models;

class Book extends \Illuminate\Database\Eloquent\Model
{
    protected $fillable = ['title'];
}
use Auth;

class BooksList extends \Crude implements \CRUDInterface, \CrudeOrderInterface
{
    use \CrudeFromModelTrait;

    public function __construct()
    {
        $this->setModel(new \App\Models\Book);

        $this->prepareCrudeSetup();

        $this->crudeSetup
            ->setTitle('List of books')
            ->setTrans(['id' => 'Id', 'title' => 'Title', 'order' => '#'])
            ->setColumnFormat('title', 'longtext');

        $this->storeInFirstPlace();

        if (! Auth:user()->cannotOrderListOfBooks())
            $this->crudeSetup->useOrderedList('title');
    }
}

/wiki/ordered_list/1.png

变更日志

请参阅CHANGELOG以获取更多信息,了解最近有哪些更改。

贡献

请参阅CONTRIBUTINGCONDUCT以获取详细信息。

安全性

如果您发现任何安全问题,请通过电子邮件jan.dolata.gd@gmail.com联系,而不是使用问题跟踪器。

致谢

许可证

MIT许可证(MIT)。请参阅许可证文件以获取更多信息。