ottiem / cruddy

一个功能强大但简单的 Laravel CRUD 构建工具。

维护者

详细信息

github.com/ottiem/cruddy

源代码

问题

安装: 45

依赖: 0

建议: 0

安全: 0

星标: 0

关注者: 1

分支: 0

类型:项目

dev-main 2022-12-05 22:56 UTC

This package is auto-updated.

Last update: 2024-09-06 02:48:14 UTC


README

为 Laravel 提供简单的 CRUD 创建包。

安装步骤

  1. composer install ottiem/cruddy
  2. php artisan vendor:publish
  3. 在新建的 config/cruddy.php 文件中调整任何设置
  4. 将 cruddy 连接添加到所有创建您想要转换为基本 CRUD 资源表的迁移中: Schema::connection('cruddy')

供应商包文件

当您运行 php artisan vendor:publish 时,它将在 config/cruddy.php 中为您创建一个配置文件。这是您设置所有 CRUD 设置和选项的地方。例如,config/cruddy.php 中的 needs_ui 变量控制是否创建前端视图文件。如果您正在创建一个不需要前端 API,则应将此值设置为 false,以便不创建视图文件。

数据库连接

在运行迁移之前正确设置数据库连接,您的 .env 文件中的 APP_ENV 变量不能设置为 testinglocal

  // Within config/cruddy.php, we can control the creation of the frontend view files like so:
 'needs_ui' => false,

示例

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

如果这些文件尚不存在,则将根据上述示例创建它们。如果文件已存在,则不会覆盖。

  1. app/Http/Controllers/FooController.php
  2. app/Models/Foo.php
  3. app/Http/Requests/StoreFoo.php
  4. app/Http/Requests/UpdateFoo.php
  5. resources/views/foo/create.blade.php
  6. resources/views/foo/edit.blade.php
  7. resources/views/foo/index.blade.php
  8. resources/views/foo/show.blade.php

这将添加到上述示例的 routes/web.php 文件中

// Foo Resource
Route::resource('foos', 'App\Http\Controllers\FooController');