Level 1
When WithFileUploads has completed the upload, it emits an upload:finished event. You can listen for that and then show a message.
/**
* Listens for the upload:finished event and calls the uploadDocument method.
*/
public $listeners = [
'upload:finished' => 'uploadDocument',
];
/**
* Validates the uploaded document and displays a success message.
*
* @param string $documentModel The name of the document model.
* @return void
*/
public function uploadDocument($documentModel)
{
// Validate the uploaded document
$this->validate([
$documentModel => 'required|mimes:pdf,jpg,jpeg,png|max:1024',
],[
$documentModel.'.required' => 'The document is required',
$documentModel.'.mimes' => 'The document format must be either .pdf, .jpg, .jpeg or .png',
]);
// Display a success message
// TODO: Replace this with your own code to display the success message in the view
}
1 like