<?php

namespace Modules\Jiesuan\Services;

use Illuminate\Support\Facades\DB;

class BusinessmanService
{
    /**
     *  商务列表
     * name: list
     * @param array $param
     * @return \Illuminate\Support\Collection
     * date 2023/05/30 10:01
     */
    public static function list($param = []) {
        $list = DB::table('users')
            ->join('user_has_roles', 'users.id', 'user_has_roles.user_id')
            ->join('roles', 'user_has_roles.role_id', 'roles.id')
            ->where([
                'roles.identify' => 'business',
                'users.status' => 1,
            ]);
        if (getProp($param,'name','')){
            $list->where('users.username','like',"%".$param['name']."%");
        }
        if (getProp($param,'id',0)){
            $list->where('users.id',$param['id']);
        }
        return $list->select('users.id', 'users.username', 'users.email')
            ->get();
    }
}
