From 79898d87c0328b9c4f7adb782bb4161e020d02b4 Mon Sep 17 00:00:00 2001 From: kuaifan Date: Sat, 1 Apr 2023 16:54:13 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=96=87=E4=BB=B6=E6=90=9C=E7=B4=A2?= =?UTF-8?q?=E4=B8=8D=E5=88=B0=E6=A0=B9=E7=9B=AE=E5=BD=95=E7=9A=84=E5=85=B1?= =?UTF-8?q?=E4=BA=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Models/File.php | 1 + .../2023_04_01_164418_update_file_pshare.php | 26 +++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 database/migrations/2023_04_01_164418_update_file_pshare.php diff --git a/app/Models/File.php b/app/Models/File.php index 911b1d1fd..615f85520 100644 --- a/app/Models/File.php +++ b/app/Models/File.php @@ -181,6 +181,7 @@ class File extends AbstractModel if ($this->share != $share) { AbstractModel::transaction(function () use ($share) { $this->share = $share; + $this->pshare = $share ? $this->id : 0; $this->save(); File::where("pids", "like", "%,{$this->id},%")->update(['pshare' => $share ? $this->id : 0]); if ($share === 0) { diff --git a/database/migrations/2023_04_01_164418_update_file_pshare.php b/database/migrations/2023_04_01_164418_update_file_pshare.php new file mode 100644 index 000000000..b7372739f --- /dev/null +++ b/database/migrations/2023_04_01_164418_update_file_pshare.php @@ -0,0 +1,26 @@ +wherePshare(0)->update(['pshare' => DB::raw('id')]); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + // + } +}