Skip to content

Commit 42a5162

Browse files
author
李强
committed
fix: Compatible with thinkorm4.0
1 parent b068fb4 commit 42a5162

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

.github/workflows/phpunit.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ jobs:
1919
strategy:
2020
fail-fast: true
2121
matrix:
22-
php: [ 8.0, 8.1, 8.2, 8.3, 8.4 ]
22+
php: [ 8.0, 8.1, 8.2, 8.3 ]
23+
thinkphp: [ "~8.0.3", "^8.1"]
2324

24-
name: PHP${{ matrix.php }}
25+
name: ThinkPHP${{ matrix.thinkphp }}-PHP${{ matrix.php }}
2526

2627
steps:
2728
- name: Checkout code
@@ -42,13 +43,15 @@ jobs:
4243
uses: actions/cache@v3
4344
with:
4445
path: vendor
45-
key: ${{ runner.os }}-${{ matrix.php }}-${{ hashFiles('**/composer.lock') }}
46+
key: ${{ runner.os }}-${{ matrix.php }}-${{ matrix.thinkphp }}-${{ hashFiles('**/composer.lock') }}
4647
restore-keys: |
47-
${{ runner.os }}-${{ matrix.php }}
48+
${{ runner.os }}-${{ matrix.php }}-${{ matrix.thinkphp }}
4849
4950
- name: Install dependencies
5051
if: steps.composer-cache.outputs.cache-hit != 'true'
51-
run: composer install --prefer-dist --no-progress --no-suggest
52+
run: |
53+
composer require topthink/framework:${{ matrix.thinkphp }} --no-update --no-interaction
54+
composer install --prefer-dist --no-progress --no-suggest
5255
5356
- name: Run test suite
5457
run: ./vendor/bin/phpunit

src/model/Rule.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,18 @@
1212
class Rule extends Model implements Arrayable
1313
{
1414
use Configurable;
15+
16+
protected $name;
17+
18+
// 设置当前模型对应的完整数据表名称
19+
protected $table;
20+
21+
// 设置当前模型的数据库连接
22+
protected $connection;
23+
24+
// 默认主键
25+
protected $pk = 'id';
26+
1527
/**
1628
* 设置字段信息
1729
*
@@ -37,6 +49,7 @@ public function __construct(array|object $data = [])
3749
$this->connection = $this->config('database.connection') ?: '';
3850
$this->table = $this->config('database.rules_table');
3951
$this->name = $this->config('database.rules_name');
52+
4053
parent::__construct($data);
4154
}
4255
}

0 commit comments

Comments
 (0)