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.
 
 

30 lines
803 B

<?php
namespace App\Service;
use App\Model\UserRelationBind;
class CommunityService implements CommunityServiceInterface
{
public function bind($data)
{
if ($res = $this->isBinded($data['bind_type'], $data['source_id'], $data['user_id'])) {
return $res;
}
return UserRelationBind::query()->updateOrCreate(
['bind_type' => $data['bind_type'], 'source_id' => $data['source_id'], 'user_id' => $data['user_id']],
['json_data' => $data['json_data']]
);
}
public function isBinded($bind_type, $source_id, $user_id)
{
return UserRelationBind::query()
->select('id')
->where(['bind_type' => $bind_type, 'source_id' => $source_id, 'user_id' => $user_id])
->first();
}
}