Description
Add support for file and image uploads in generated CRUDs.
Proposed Syntax
php artisan crudify:generate Product \
--fields="name:string,photo:file,images:file:multiple,brochure:file:pdf"
Generated Components
- Migration: Add
photo as string (path storage) or text (JSON array for multiple)
- Model: Handle file casts and accessors
- Livewire Create/Edit: Add
<input type="file" wire:model="photo"> with @livewireScripts handling
- Index: Show thumbnail previews in table
- Show: Display full image or download link
- Factory: Use
UploadedFile::fake()->image() for testing
Key Considerations
Example
// In Livewire Create component
#[Validate(['photo' => 'nullable|image|max:2048'])]
public $photo;
public function save(): void
{
$validated = $this->validate();
if ($this->photo) {
$validated['photo'] = $this->photo->store('products', 'public');
}
Product::create($validated);
}
Description
Add support for file and image uploads in generated CRUDs.
Proposed Syntax
php artisan crudify:generate Product \ --fields="name:string,photo:file,images:file:multiple,brochure:file:pdf"Generated Components
photoasstring(path storage) ortext(JSON array for multiple)<input type="file" wire:model="photo">with@livewireScriptshandlingUploadedFile::fake()->image()for testingKey Considerations
Example