where([ ['sha1', '=', $model->sha1], ['topic', '=', $model->topic], ['storage', '=', $model->storage], ])->find(); if ($repeat) { $storageFile = path_transform(public_path() . ltrim($repeat['url'], '/')); if (!file_exists($storageFile)) { $repeat->delete(); return true; } else { $repeat->quote++; $repeat->lastuploadtime = time(); $repeat->save(); return false; } } return true; } protected static function onAfterInsert($model) { if (!$model->lastuploadtime) { $model->quote = 1; $model->lastuploadtime = time(); $model->save(); } } public function admin() { return $this->belongsTo(Admin::class); } public function user() { return $this->belongsTo(User::class); } }