You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
65 lines
2.2 KiB
65 lines
2.2 KiB
4 years ago
|
<?php
|
||
|
|
||
|
namespace App\Models;
|
||
|
|
||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||
|
use Illuminate\Database\Eloquent\Model;
|
||
|
|
||
|
/**
|
||
|
* This is the model class for table "uc_employee_group_t".
|
||
|
*
|
||
|
* @property $id bigint
|
||
|
* @property $pid bigint
|
||
|
* @property $title varchar
|
||
|
* @property $level tinyint
|
||
|
* @property $description varchar
|
||
|
* @property $base_salary decimal
|
||
|
* @property $status tinyint
|
||
|
* @property $rules varchar
|
||
|
* @property $created_at timestamp
|
||
|
* @property $updated_at timestamp
|
||
|
*/
|
||
|
class EmployeeGroupT extends Model
|
||
|
{
|
||
|
use HasFactory;
|
||
|
|
||
|
protected $table = 'uc_employee_group_t';
|
||
|
|
||
|
public $attrs = [
|
||
|
'pid' => ['name' => 'pid', 'title' => '父ID', 'type' => 'bigint', 'is_must' => '0'],
|
||
|
'title' => ['name' => 'title', 'title' => '岗位名称', 'type' => 'varchar', 'is_must' => '1'],
|
||
|
'level' => ['name' => 'level', 'title' => '数据等级', 'type' => 'tinyint', 'is_must' => '0'],
|
||
|
'description' => ['name' => 'description', 'title' => '岗位描述', 'type' => 'varchar', 'is_must' => '0'],
|
||
|
'base_salary' => ['name' => 'base_salary', 'title' => '基础工资', 'type' => 'decimal', 'is_must' => '0'],
|
||
|
'status' => ['name' => 'status', 'title' => '岗位状态: 1 开启 2 关闭', 'type' => 'tinyint', 'is_must' => '0'],
|
||
|
'rules' => ['name' => 'rules', 'title' => '规则id,多个规则 , 隔开', 'type' => 'varchar', 'is_must' => '0'],
|
||
|
];
|
||
|
|
||
|
public function getTree($status, $pid = 0)
|
||
|
{
|
||
|
$data = [];
|
||
|
if($status){
|
||
|
$this->where('status', $status);
|
||
|
}
|
||
|
$list = $this->where('pid', $pid)->get();
|
||
|
foreach ($list as $item) {
|
||
|
$row = [
|
||
|
'id' => $item->id,
|
||
|
'pid' => $item->pid,
|
||
|
'title' => $item->title,
|
||
|
'level' => $item->level,
|
||
|
'description' => $item->description,
|
||
|
'base_salary' => $item->base_salary,
|
||
|
'status' => $item->status,
|
||
|
'rules' => $item->rules,
|
||
|
];
|
||
|
$children = $this->getTree($status, $item->id);
|
||
|
if(count($children) > 0){
|
||
|
$row['children'] = $children;
|
||
|
}
|
||
|
$data[] = $row;
|
||
|
}
|
||
|
return $data;
|
||
|
}
|
||
|
}
|