PdfFile.php 2.2 KB
<?php

namespace App\Models\File;

use App\Models\Base;

/**
 * App\Models\File\PdfFile
 *
 * @property int $id
 * @property int $pid AICC用户ID
 * @property string $file_path 生成文件路径
 * @property int $is_pdf 0 - 未生成 1 - 已生成 2 - 其它问题
 * @property int|null $is_push 0 - 未推送 1 - 已推送 2 - 其他问题
 * @property \Illuminate\Support\Carbon|null $created_at
 * @property \Illuminate\Support\Carbon|null $updated_at
 * @method  \Illuminate\Database\Eloquent\Builder|PdfFile newModelQuery()
 * @method  \Illuminate\Database\Eloquent\Builder|PdfFile newQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|PdfFile query()
 * @method  \Illuminate\Database\Eloquent\Builder|PdfFile whereCreatedAt($value)
 * @method  \Illuminate\Database\Eloquent\Builder|PdfFile whereFilePath($value)
 * @method  \Illuminate\Database\Eloquent\Builder|PdfFile whereId($value)
 * @method  \Illuminate\Database\Eloquent\Builder|PdfFile whereIsPdf($value)
 * @method  \Illuminate\Database\Eloquent\Builder|PdfFile whereIsPush($value)
 * @method  \Illuminate\Database\Eloquent\Builder|PdfFile wherePid($value)
 * @method  \Illuminate\Database\Eloquent\Builder|PdfFile whereUpdatedAt($value)
 * @mixin \Eloquent
 */
class PdfFile extends Base
{
    protected $table = 'gl_pdf_file';

    /** @var int PDF - 未生成 */
    const GENERATE_NOT_PDF = 0;

    /** @var int PDF - 已生成 */
    const GENERATE_PDF = 1;

    /** @var int PDF - 其它问题 */
    const GENERATE_OTHER_PDF = 2;

    /** @var int AICC - 未推送 */
    const GENERATE_NOT_PUSH = 0;
    /** @var int AICC - 已推送 */
    const GENERATE_PUSH = 1;
    /** @var int AICC - 其他问题 */
    const GENERATE_OTHER_PUSH = 2;

    public function saveData(array $data): bool
    {
        # v6项目ID
        $pid   = (int)$data['pid'] ?? 0;
        $time = $data['time'] ?? date('Y-m-d');
        $isRes = self::query()->wherePid($pid)->where('created_at', 'like', $time . '%')->first();
        if (!$isRes) {
            $isRes      = new self();
            $isRes->pid = $pid;
            # 生成文件路径
            $isRes->file_path = $data['file_path'] ?? '';
        }
        return $isRes->save();
    }

}