52 lines
1.2 KiB
PHP
52 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use CodeIgniter\Model;
|
|
|
|
class ChartExportModel extends Model
|
|
{
|
|
protected $table = 'chart_exports';
|
|
protected $primaryKey = 'id';
|
|
protected $useAutoIncrement = true;
|
|
protected $returnType = 'array';
|
|
protected $protectFields = true;
|
|
|
|
protected $allowedFields = [
|
|
'workspace_id',
|
|
'chart_id',
|
|
'dashboard_id',
|
|
'export_type',
|
|
'file_path',
|
|
'file_size',
|
|
'exported_by',
|
|
];
|
|
|
|
protected bool $allowEmptyInserts = false;
|
|
|
|
protected $useTimestamps = false;
|
|
|
|
/**
|
|
* @param 'png'|'svg'|'csv'|'excel'|'pdf' $type
|
|
*/
|
|
public function logExport(
|
|
int $workspaceId,
|
|
int $exportedBy,
|
|
string $type,
|
|
?int $chartId = null,
|
|
?int $dashboardId = null,
|
|
?string $filePath = null,
|
|
?int $fileSize = null
|
|
): void {
|
|
$this->insert([
|
|
'workspace_id' => $workspaceId,
|
|
'chart_id' => $chartId,
|
|
'dashboard_id' => $dashboardId,
|
|
'export_type' => $type,
|
|
'file_path' => $filePath,
|
|
'file_size' => $fileSize,
|
|
'exported_by' => $exportedBy,
|
|
]);
|
|
}
|
|
}
|