ottiem / cruddy
A powerful but simple CRUD builder for Laravel.
Requires
- php: >=7.0
- illuminate/console: >=8.0
- illuminate/database: >=8.0
- illuminate/routing: >=8.0
- illuminate/support: >=8.0
- orchestra/testbench: >=6.0.0
- symfony/console: >=5.0
Requires (Dev)
- phpunit/phpunit: ^9.5
This package is auto-updated.
Last update: 2024-05-06 02:10:07 UTC
README
Simple CRUD creation package for Laravel.
Steps to Install
- composer install ottiem/cruddy
- php artisan vendor:publish
- adjust any settings in the newly created config/cruddy.php file
- add the cruddy connection to all migrations that create the table you want to turn into a basic CRUD resource:
Schema::connection('cruddy')
Vendor Package files:
When you run php artisan vendor:publish
it will create a config file for you in config/cruddy.php. This is where you can set all your CRUD settings and options. For example, the needs_ui
variable within config/cruddy.php controls whether to create the frontend view files or not. If you are making an API that does not require a frontend, then you should set this value to false so that the view files will not be created.
Database Connection
To set the database connection correctly before running the migrations, the APP_ENV
variable within your .env file cannot be set to testing
or local
.
// Within config/cruddy.php, we can control the creation of the frontend view files like so:
'needs_ui' => false,
Example:
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateFooTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::connection('cruddy')->create('foos', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('bar');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('foos');
}
}
If these files do not already exist, then they will be created from running the example above. Files will not be overwritten if they already exist.
- app/Http/Controllers/FooController.php
- app/Models/Foo.php
- app/Http/Requests/StoreFoo.php
- app/Http/Requests/UpdateFoo.php
- resources/views/foo/create.blade.php
- resources/views/foo/edit.blade.php
- resources/views/foo/index.blade.php
- resources/views/foo/show.blade.php
This will be added to your routes/web.php file for the example above:
// Foo Resource
Route::resource('foos', 'App\Http\Controllers\FooController');