Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
3 / 3
CRAP
100.00% covered (success)
100.00%
18 / 18
DocumentUploaded
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
3 / 3
3
100.00% covered (success)
100.00%
18 / 18
 __construct
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
2 / 2
 getFields
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
15 / 15
 getFieldMetaData
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
<?php
namespace BristolSU\Module\UploadFile\Events;
use BristolSU\Module\UploadFile\Models\File;
use BristolSU\Support\Action\Contracts\TriggerableEvent;
class DocumentUploaded implements TriggerableEvent
{
    public $file;
    public function __construct(File $file)
    {
        $this->file = $file;
    }
    public function getFields(): array
    {
        return [
            'file_id' => $this->file->id,
            'title' => $this->file->title,
            'description' => $this->file->description,
            'filename' => $this->file->filename,
            'mime' => $this->file->mime,
            'size' => $this->file->size,
            'uploaded_by_id' => $this->file->uploaded_by->id(),
            'uploaded_by_email' => $this->file->uploaded_by->data()->email(),
            'uploaded_by_first_name' => $this->file->uploaded_by->data()->firstName(),
            'uploaded_by_last_name' => $this->file->uploaded_by->data()->lastName(),
            'uploaded_by_preferred_name' => $this->file->uploaded_by->data()->preferredName(),
            'module_instance_id' => $this->file->module_instance_id,
            'activity_instance_id' => $this->file->activity_instance_id,
            'uploaded_at' => $this->file->created_at->format('Y-m-d H:i:s'),
            'updated_at' => $this->file->updated_at->format('Y-m-d H:i:s'),
        ];
    }
    public static function getFieldMetaData(): array
    {
        return [
            'file_id' => [
                'label' => 'File ID',
                'helptext' => 'The ID of the file'
            ],
            'title' => [
                'label' => 'Title',
                'helptext' => 'The title given to the document when uploaded',
            ],
            'description' => [
                'label' => 'Description',
                'helptext' => 'A description of the file'
            ],
            'filename' => [
                'label' => 'Filename',
                'helptext' => 'The original filename of the document'
            ],
            'mime' => [
                'label' => 'Mimetype',
                'helptext' => 'The mime type of the file'
            ],
            'size' => [
                'label' => 'File Size',
                'helptext' => 'The size of the file in bytes'
            ],
            'uploaded_by_id' => [
                'label' => 'User ID',
                'helptext' => 'ID of the user who uploaded the file'
            ],
            'uploaded_by_email' => [
                'label' => 'User Email',
                'helptext' => 'Email of the user who uploaded the file'
            ],
            'uploaded_by_first_name' => [
                'label' => 'User First Name',
                'helptext' => 'First Name of the user who uploaded the file'
            ],
            'uploaded_by_last_name' => [
                'label' => 'User Last Name',
                'helptext' => 'Last Name of the user who uploaded the file'
            ],
            'uploaded_by_preferred_name' => [
                'label' => 'User Preferred Name',
                'helptext' => 'Preferred Name of the user who uploaded the file'
            ],
            'module_instance_id' => [
                'label' => 'Module Instance ID',
                'helptext' => 'ID of the module instance the file was uploaded to'
            ],
            'activity_instance_id' => [
                'label' => 'Activity Instance ID',
                'helptext' => 'ID of the activity instance that uploaded the file'
            ],
            'uploaded_at' => [
                'label' => 'Uploaded At',
                'helptext' => 'Time and date the file was uploaded at'
            ],
            'updated_at' => [
                'label' => 'Updated At',
                'helptext' => 'Time and date the file was last updated'
            ]
        ];
    }
}