mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-12 11:19:56 +00:00
no message
This commit is contained in:
parent
b1e35e6824
commit
9d56dd122f
@ -6,9 +6,10 @@ namespace App\Models;
|
|||||||
* App\Models\FileLink
|
* App\Models\FileLink
|
||||||
*
|
*
|
||||||
* @property int $id
|
* @property int $id
|
||||||
* @property int|null $file_id 项目ID
|
* @property int|null $file_id 文件ID
|
||||||
* @property int|null $num 累计访问
|
* @property int|null $num 累计访问
|
||||||
* @property string|null $code 链接码
|
* @property string|null $code 链接码
|
||||||
|
* @property int|null $userid 会员ID
|
||||||
* @property \Illuminate\Support\Carbon|null $created_at
|
* @property \Illuminate\Support\Carbon|null $created_at
|
||||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||||
* @property-read \App\Models\File|null $file
|
* @property-read \App\Models\File|null $file
|
||||||
@ -21,6 +22,7 @@ namespace App\Models;
|
|||||||
* @method static \Illuminate\Database\Eloquent\Builder|FileLink whereId($value)
|
* @method static \Illuminate\Database\Eloquent\Builder|FileLink whereId($value)
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|FileLink whereNum($value)
|
* @method static \Illuminate\Database\Eloquent\Builder|FileLink whereNum($value)
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|FileLink whereUpdatedAt($value)
|
* @method static \Illuminate\Database\Eloquent\Builder|FileLink whereUpdatedAt($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|FileLink whereUserid($value)
|
||||||
* @mixin \Eloquent
|
* @mixin \Eloquent
|
||||||
*/
|
*/
|
||||||
class FileLink extends AbstractModel
|
class FileLink extends AbstractModel
|
||||||
|
|||||||
@ -13,11 +13,23 @@ class AddFileLinksUserid extends Migration
|
|||||||
*/
|
*/
|
||||||
public function up()
|
public function up()
|
||||||
{
|
{
|
||||||
|
$isAdd = false;
|
||||||
Schema::table('file_links', function (Blueprint $table) {
|
Schema::table('file_links', function (Blueprint $table) {
|
||||||
if (!Schema::hasColumn('file_links', 'userid')) {
|
if (!Schema::hasColumn('file_links', 'userid')) {
|
||||||
|
$isAdd = true;
|
||||||
$table->integer('userid')->nullable()->default(0)->after('code')->comment('会员ID');
|
$table->integer('userid')->nullable()->default(0)->after('code')->comment('会员ID');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
if ($isAdd) {
|
||||||
|
// 更新数据
|
||||||
|
\App\Models\FileLink::chunkById(100, function ($lists) {
|
||||||
|
/** @var \App\Models\FileLink $item */
|
||||||
|
foreach ($lists as $item) {
|
||||||
|
$item->userid = intval(\App\Models\File::whereId($item->file_id)->value('userid'));
|
||||||
|
$item->save();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user