jan-dolata/crude-crud

Crude CRUD for Laravel

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

README

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

Full documentation

Table of content

Install

Via Composer

$ composer require jan-dolata/crude-crud

Add ServiceProvider to config/app.

JanDolata\CrudeCRUD\CrudeCRUDServiceProvider::class

Publish and migrate

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

Check config file config/crude.php.

Usage

create dir app/Engine/Crude

in app/Engine/Crude directory create class for list

<?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();
    }

}

in controller action

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

in view

@include('CrudeCRUD::start')

it works.

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

Example

Part of create books table migration

    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

Change log

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING and CONDUCT for details.

Security

If you discover any security related issues, please email jan.dolata.gd@gmail.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.