Description
Generate CRUDs for nested resources (e.g., Posts → Comments, Projects → Tasks).
Proposed Syntax
# Generate Comment CRUD nested under Post
php artisan crudify:generate Comment \
--fields="body:text" \
--relationships="post:belongsTo:Post" \
--nested=Post
Generated Components
Example Routes
Route::get('/posts/{post}/comments', Comment\Index::class)->name('posts.comments.index');
Route::get('/posts/{post}/comments/create', Comment\Create::class)->name('posts.comments.create');
Route::get('/posts/{post}/comments/{comment}', Comment\Show::class)->name('posts.comments.show');
Example Livewire Create
class Create extends Component
{
public Post $post;
public string $body = '';
public function mount(Post $post): void
{
$this->post = $post;
}
public function save(): void
{
$validated = $this->validate();
$this->post->comments()->create($validated);
$this->redirectRoute('posts.comments.index', $this->post);
}
}
Key Considerations
Description
Generate CRUDs for nested resources (e.g., Posts → Comments, Projects → Tasks).
Proposed Syntax
Generated Components
/posts/{post}/comments,/posts/{post}/comments/{comment}post->comments()->create()Posts > {post title} > CommentsExample Routes
Example Livewire Create
Key Considerations