Exemple #1
0
 /**
  * @param $grantType
  * @param ActiveQuery|null $query
  * @return ActiveQuery
  */
 public static function findByGrantType($grantType, ActiveQuery $query = null)
 {
     $query = $query ?: static::find();
     return $query->andWhere(['id' => ClientGrantsModel::findByGrantType($grantType)->select(['client_id'])]);
 }
 /**
  * @param  string $clientIdentifier
  * @param  string $grant |null
  * @return boolean
  */
 public function removeClientGrant($clientIdentifier, $grant = null)
 {
     $condition = ['client_id' => $clientIdentifier];
     if ($grant) {
         $condition['grant_id'] = $grant;
     }
     $grants = ClientGrantsModel::findAll($condition);
     $db = CommonModel::getDb();
     $transaction = $db->beginTransaction();
     try {
         foreach ($grants as $grant) {
             $grant->delete();
         }
         $transaction->commit();
         return true;
     } catch (\Exception $e) {
         $transaction->rollBack();
         return false;
     }
 }
Exemple #3
0
 /**
  * @return ActiveQuery
  */
 public function getClientGrants()
 {
     return $this->hasMany(ClientGrantsModel::className(), ['grant_id' => 'id']);
 }