goodyweb / jetstream-crud
为 Jetstream 实现 创建、读取、更新和删除操作
dev-master
2023-12-10 09:21 UTC
Requires
- illuminate/console: ^10.35
- illuminate/support: ^10.35
- livewire/livewire: ^3.2
This package is not auto-updated.
Last update: 2024-09-30 08:30:56 UTC
README
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
文件,你可以通过源代码仓库的默认内容创建一个。
使用方法
-
按照通常的方式创建数据库表
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
- 进行一些编辑
-
按照通常的方式为数据库表创建 Eloquent 模型
php artisan make:model Person
-
为 CRUD 模块生成 Livewire 组件和 Blade 模板
php artisan generate:crud --model=Person --livewire=Persons