43 lines
1.1 KiB
PHP
43 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace Modules\DailyReports\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Spatie\MediaLibrary\HasMedia;
|
|
use Spatie\MediaLibrary\InteractsWithMedia;
|
|
|
|
class DailyReportActivity extends Model implements HasMedia
|
|
{
|
|
use InteractsWithMedia;
|
|
|
|
protected $appends = ['evidence_urls'];
|
|
|
|
protected $fillable = [
|
|
'daily_report_id',
|
|
'task_name',
|
|
'quantity_completed',
|
|
'percentage_completed',
|
|
'zone_area',
|
|
];
|
|
|
|
public function getEvidenceUrlsAttribute(): array
|
|
{
|
|
return $this->getMedia('evidence')->map(function ($media) {
|
|
return [
|
|
'id' => $media->id,
|
|
'name' => $media->name,
|
|
'file_name' => $media->file_name,
|
|
'original_url' => $media->original_url,
|
|
'mime_type' => $media->mime_type,
|
|
'size' => $media->size,
|
|
];
|
|
})->toArray();
|
|
}
|
|
|
|
public function dailyReport(): BelongsTo
|
|
{
|
|
return $this->belongsTo(DailyReport::class);
|
|
}
|
|
}
|