ycs77/laravel-crud-page

This package is abandoned and no longer maintained. No replacement package was suggested.

Fast generate CRUD pages, controllers of the Laravel.

v1.0.1 2019-05-30 14:01 UTC

This package is auto-updated.

Last update: 2020-04-30 00:56:52 UTC


README

Latest Version on Packagist Software License Total Downloads

Fast generate CRUD pages, controllers of the Laravel.

This package is for users to use, NOT administrator.

Installation

Via Composer:

composer require ycs77/laravel-crud-page

Publish config (Required):

php artisan vendor:publish --tag=laravel-crud-page
php artisan vendor:publish --tag=laravel-form-builder-bs4
php artisan vendor:publish --tag=laravel-form-field-type-config

Usage

Config

Add your resource to config:

config/crud-page.php

'resources' => [
    // ...

    'post' => [
        'model' => '\App\Post',
        'controller' => '\App\Http\Controllers\PostController',
        'file_store' => 'posts',
        'view_name' => null,
        'actions' => [
            'index' => true,
            'create' => true,
            'show' => true,
            'edit' => true,
            'delete' => true,
        ],
    ],
],

Controller

Create controller:

php artisan make:crud:controller PostController

Created a new CRUD controller:

class PostController extends CrudController
{
    /**
     * Get table fields.
     *
     * @see https://github.com/KABBOUCHI/laravel-table-view#usage
     * 
     * @return array
     */
    protected function getTableFields()
    {
        return [
            'Title' => 'title',
        ];
    }

    /**
     * Get form fields.
     * 
     * @see https://github.com/ycs77/laravel-form-field-type
     * 
     * @return array
     */
    protected function formFields()
    {
        return [
            'title' => [
                'type' => 'text',
                'rules' => 'required|max:50',
            ],
            'content' => [
                'type' => 'textarea',
                'rules' => 'required',
            ],
            'submit',
        ];
    }
}

Routes

Add resources routes (resource post is example):

config/crud-page.php

CrudPage::routes('post');

View

If you want override view, can create view to views folder posts/index. (posts is resource name, index is action).

LICENSE

MIT LICENSE