goodyweb/jetstream-crud

为 Jetstream 实现 创建、读取、更新和删除操作

安装次数: 5

依赖项: 0

建议者: 0

安全: 0

星标: 0

关注者: 2

分支: 0

开放问题: 0

类型:laravel-package

dev-master 2023-12-10 09:21 UTC

This package is not auto-updated.

Last update: 2024-09-30 08:30:56 UTC


README

Laravel logo Composer logo

Jetstream CRUD

此 Laravel 包生成基本的 Livewire 组件和 Blade 模板,使您能够操作特定数据库表的记录。模块包括

  • Create
  • Read
  • Update
  • Delete
  • 搜索
  • 分页

入门

此包通过发出单个命令即可轻松创建完整的 CRUD 模块

php artisan generate:crud --model=Person --livewire=Persons

成功了!

请参阅安装配置使用部分以获取详细信息。

安装

composer require goodyweb/jetstream-crud dev-master

配置

在你的 Livewire 配置文件(config/livewire.php)中,将 legacy_model_binding 选项设置为 true,如下所示

'legacy_model_binding' => true,

重要:如果你没有 config/livewire.php 文件,你可以通过源代码仓库的默认内容创建一个。

使用方法

  1. 按照通常的方式创建数据库表

    php artisan make:migration create_persons_table --create=persons
    • 进行一些编辑
        <?php
      
        use Illuminate\Database\Migrations\Migration;
        use Illuminate\Database\Schema\Blueprint;
        use Illuminate\Support\Facades\Schema;
      
        return new class extends Migration
        {
            /**
            * Run the migrations.
            */
            public function up(): void
            {
                Schema::create('persons', function (Blueprint $table) {
                    $table->id();
                    // add something columns here maybe
                    $table->timestamps();
                });
            }
      
            /**
            * Reverse the migrations.
            */
            public function down(): void
            {
                Schema::dropIfExists('persons');
            }
        };
    • 执行创建表的真正操作
      php artisan migrate
  2. 按照通常的方式为数据库表创建 Eloquent 模型

    php artisan make:model Person
  3. 为 CRUD 模块生成 Livewire 组件和 Blade 模板

    php artisan generate:crud --model=Person --livewire=Persons