Stakeholder.php
1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
namespace App\Models\Legal;
use App\Models\BaseModel;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\SoftDeletes;
/**
* Class Stakeholder
* @package App\Models\Legal
*/
class Stakeholder extends BaseModel
{
use HasFactory,SoftDeletes;
/**
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function detail()
{
return $this->hasMany(StakeholderBankDetail::class, 'stakeholder_id', 'id');
}
/**
* 获取用户的所有关联id
* @param object $identifier
* @return array
*/
public static function stakeholderIds(object $identifier)
{
switch (intval($identifier->type)) {
case 1:
//个人
$stakeholder= Stakeholder::query()->join('stakeholder_detail as sd', 'stakeholders.id', '=', 'sd.stakeholder_id')
->where(['stakeholders.card_no'=>$identifier->identifier])->pluck('stakeholders.id')->toArray();
break;
case 2:
$stakeholder = Stakeholder::query()->where(['type' => 2, 'credit_code' => $identifier->identifier])->pluck('id')->toArray();
break;
default:
return [];
}
return array_unique($stakeholder);
}
}