質問編集履歴
3
修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
以下ようなメソッドで元のDBから合計値を算出し描写しています。
|
2
|
+
|
3
|
+
エラーコード
|
2
4
|
|
3
5
|
> SQLSTATE[42S22]: Column not found: 1054 Unknown column 'tb_user_department.total_over_working_time' in 'where clause' (SQL: select count(*) as aggregate from `tb_user_department` where exists (select * from `tb_department` where `tb_department`.`department_id` = `tb_user_department`.`department_id`) and exists (select * from `tb_user` where `tb_user`.`user_id` = `tb_user_department`.`user_id`) and `tb_user_department`.`total_over_working_time` between 21 and 50)
|
4
6
|
|
@@ -40,7 +42,7 @@
|
|
40
42
|
|
41
43
|
{
|
42
44
|
|
43
|
-
return $
|
45
|
+
return $query->whereBetween('tb_user_department.total_over_working_time', [0,20]);
|
44
46
|
|
45
47
|
}
|
46
48
|
|
2
加筆
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
以下ようなメソッドで元のDBから合計値を算出し描写しています。
|
2
|
+
|
3
|
+
> SQLSTATE[42S22]: Column not found: 1054 Unknown column 'tb_user_department.total_over_working_time' in 'where clause' (SQL: select count(*) as aggregate from `tb_user_department` where exists (select * from `tb_department` where `tb_department`.`department_id` = `tb_user_department`.`department_id`) and exists (select * from `tb_user` where `tb_user`.`user_id` = `tb_user_department`.`user_id`) and `tb_user_department`.`total_over_working_time` between 21 and 50)
|
2
4
|
|
3
5
|
```php
|
4
6
|
|
1
途中
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,3 +1,45 @@
|
|
1
|
-
|
1
|
+
以下ようなメソッドで元のDBから合計値を算出し描写しています。
|
2
2
|
|
3
|
+
```php
|
4
|
+
|
5
|
+
class DB extends Model{
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
protected $appends= ['total_over_working_time'];
|
10
|
+
|
11
|
+
getTotalOverWorkingTimeAttribute(){
|
12
|
+
|
13
|
+
//計算処理
|
14
|
+
|
15
|
+
return total_over_working_time;
|
16
|
+
|
17
|
+
}
|
18
|
+
|
19
|
+
}
|
20
|
+
|
21
|
+
```
|
22
|
+
|
23
|
+
```PHP
|
24
|
+
|
3
|
-
|
25
|
+
/*
|
26
|
+
|
27
|
+
* 残業が20時間以下の絞り込み
|
28
|
+
|
29
|
+
*
|
30
|
+
|
31
|
+
* @param Builder $query
|
32
|
+
|
33
|
+
* @return float
|
34
|
+
|
35
|
+
*/
|
36
|
+
|
37
|
+
public function scopefilterBytotalOverWorkingTime()
|
38
|
+
|
39
|
+
{
|
40
|
+
|
41
|
+
return $test->whereBetween('tb_user_department.total_over_working_time', [0,20]);
|
42
|
+
|
43
|
+
}
|
44
|
+
|
45
|
+
```
|