kilroyweb/cruddy

Laravel CRUD Helper

1.0.2 2016-12-12 21:37 UTC

This package is not auto-updated.

Last update: 2024-11-18 15:05:10 UTC


README

#Cruddy

A simple Laravel CRUD helper

Install

composer require kilroyweb/cruddy

In config/app.php 'providers':

KilroyWeb\Cruddy\CruddyServiceProvider::class,

In config/app.php 'facades':

'Cruddy'=> KilroyWeb\Cruddy\Facades\Cruddy::class,

Usage

Controllers:

Create new controllers extending the CruddyController via:

<?php

namespace App\Http\Controllers\Books;

use KilroyWeb\Cruddy\Controllers\CruddyController;

class BookController extends CruddyController{

    protected $model = \App\Book::class;

}

This will create a controller with the following: methods

  • index: returns a variable with all models with a plural name of the model (ie: $books)
  • create
  • store: stores the model and redirects to /index with a success message
  • edit: returns a variable with the given model id with a singular name of the model (ie: $book)
  • update: updates the model and redirects to /index with a success message
  • destroy: deletes the model and redirects to /index with a success message