1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- <?php
- namespace App\Models;
- use Illuminate\Support\Facades\Log;
- class UserPhoneDetail extends Model
- {
- protected $table = 'user_phone_details';
- protected $fillable = ['brand','model','system','platform','version','SDKVersion','locationEnabled','locationAuthorized','user_id','detail'];
- public function user(){
- return $this->belongsTo(User::class);
- }
- public static function Log(array $arr,int $user_id){
- $data = [];
- foreach ($arr as $v){
- $data[$v->type] = $v->value ?? 0;
- if($v->type === 'locationEnabled'){
- if($v->value == '开'){
- $value = 1;
- }else{
- $value = 0;
- }
- $data[$v->type] = $value;
- }
- if($v->type === 'locationAuthorized'){
- if($v->value == '已授权'){
- $value = 1;
- }else{
- $value = 0;
- }
- $data[$v->type] = $value;
- }
- }
- $data['user_id'] = $user_id;
- $data['detail'] = json_encode($arr);
- self::updateOrCreate($data);
- }
- }
|