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.
37 lines
807 B
37 lines
807 B
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
class StatisticsMetadata extends SoftDeletesModel
|
|
{
|
|
protected $table = 'statistics_metadata';
|
|
|
|
/**
|
|
* 根据 key 获取统计元数据
|
|
* @param string $key
|
|
* @return StatisticsMetadata|null
|
|
*/
|
|
public static function getByKey($key)
|
|
{
|
|
return self::where('key', $key)->first();
|
|
}
|
|
|
|
/**
|
|
* 获取所有统计元数据,以 key 为索引的数组
|
|
* @return array
|
|
*/
|
|
public static function getAllAsArray()
|
|
{
|
|
$items = self::all();
|
|
$result = [];
|
|
foreach ($items as $item) {
|
|
$result[$item->key] = [
|
|
'name' => $item->name,
|
|
'from' => $item->from,
|
|
'verify' => $item->verify,
|
|
];
|
|
}
|
|
return $result;
|
|
}
|
|
}
|