init
This commit is contained in:
52 files changed
+5299
No files matched your search
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace MeghdadFadaee\NovaFormCard\Tests\Fixtures;
|
||||
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Laravel\Nova\Fields\Audio;
|
||||
use Laravel\Nova\Fields\File;
|
||||
use Laravel\Nova\Fields\Image;
|
||||
use Laravel\Nova\Http\Requests\NovaRequest;
|
||||
use MeghdadFadaee\NovaFormCard\FormCard;
|
||||
use MeghdadFadaee\NovaFormCard\FormFields;
|
||||
|
||||
class FileUploadCard extends FormCard
|
||||
{
|
||||
/**
|
||||
* @var array<string, mixed>
|
||||
*/
|
||||
public static array $handled = [];
|
||||
|
||||
public function fields(NovaRequest $request): array
|
||||
{
|
||||
return [
|
||||
File::make('Attachment')->rules('required', 'file'),
|
||||
Image::make('Avatar')->rules('required', 'image'),
|
||||
Audio::make('Voice Note')->rules('required', 'file'),
|
||||
];
|
||||
}
|
||||
|
||||
public function handle(FormFields $fields, NovaRequest $request): mixed
|
||||
{
|
||||
self::$handled = [
|
||||
'attachment' => $fields->attachment instanceof UploadedFile
|
||||
? $fields->attachment->getClientOriginalName()
|
||||
: null,
|
||||
'avatar' => $fields->avatar instanceof UploadedFile
|
||||
? $fields->avatar->getClientOriginalName()
|
||||
: null,
|
||||
'voice_note' => $fields->voice_note instanceof UploadedFile
|
||||
? $fields->voice_note->getClientOriginalName()
|
||||
: null,
|
||||
];
|
||||
|
||||
return static::message('Files received.');
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user