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.

62 lines
1.5 KiB

5 months ago
<?php
namespace App\Models;
class Company extends SoftDeletesModel
{
4 weeks ago
3 weeks ago
protected $casts = ['project_users' => 'json', 'partners' => 'json'];
2 weeks ago
protected $appends = ['is_yh_invested_text'];
public function getIsYhInvestedTextAttribute()
{
$array = [
0 => '否',
1 => '是',
];
return $array[$this->is_yh_invested] ?? '';
}
4 weeks ago
5 months ago
public function users()
{
return $this->hasMany(User::class, 'company_id', 'id');
}
5 months ago
4 months ago
/**
* 地址转经纬度
*/
public static function addressTolocation($address)
{
$map = Config::getValueByKey('map_server');
$map = json_decode($map, true);
$url = "https://restapi.amap.com/v3/geocode/geo";
$params = [
'key' => $map['key'],
'address' => $address,
];
try {
$result = httpCurl($url, 'GET', $params);
$result = json_decode($result, true);
if ($result['status'] == 1) {
$location = $result['geocodes'][0]['location'];
$location = explode(',', $location);
return [
'lng' => $location[0],
'lat' => $location[1],
];
}
return [
'lng' => null,
'lat' => null,
];
} catch (\Exception $e) {
return [
'lng' => null,
'lat' => null,
];
}
}
5 months ago
}