common/repositories/ResellersRepository.php
/**
    * Store a newly created resource in storage.
    * get user Email By Id
    * Check if exists role reseller with this id
    * if exists create a new reseller fees
    * @param new resellers resourse
    */
Store a newly created resource in storage.
get user Email By Id
Check if exists role reseller with this id
if exists create a new reseller fees
@param new resellers resourse
Store a newly created resource in storage . get user Email By Id Check if exists role reseller with this id if exists create a new reseller fees @param new resellers resourse
public function createReseller($data){
        $user_id = (null != $this->getUserIdbyEmail($data['email'])) ? $this->getUserIdbyEmail($data['email']) : null;
        $authManager = \Yii::$app->authManager;
        $user_with_role_reseller = User::find()
            ->where(['id'=>$user_id])
            ->andWhere(['in', 'id', $authManager->getUserIdsByRole('reseller')])
            ->all();
        if(null != $user_id && !empty($user_with_role_reseller)){
            $this->reseller_fee->user_id = $user_id;
            $this->reseller_fee->amount = $data['amount'];
            $this->reseller_fee->percent =$data['percent'];
            $this->reseller_fee->status = $data['status'];
            return $this->reseller_fee->save(false);
        }
        return false;
    }
public function createReseller ( $ data ) { $ user_id = ( null != $ this -> getUserIdbyEmail ( $ data [ 'email' ] ) ) ? $ this -> getUserIdbyEmail ( $ data [ 'email' ] ) : null ; $ authManager = \ Yii :: $ app -> authManager ; $ user_with_role_reseller = User :: find ( ) -> where ( [ 'id' => $ user_id ] ) -> andWhere ( [ 'in' , 'id' , $ authManager -> getUserIdsByRole ( 'reseller' ) ] ) -> all ( ) ; if ( null != $ user_id && ! empty ( $ user_with_role_reseller ) ) { $ this -> reseller_fee -> user_id = $ user_id ; $ this -> reseller_fee -> amount = $ data [ 'amount' ] ; $ this -> reseller_fee -> percent = $ data [ 'percent' ] ; $ this -> reseller_fee -> status = $ data [ 'status' ] ; return $ this -> reseller_fee -> save ( false ) ; } return false ; }
Store a newly created resource in storage.
Store a newly created resource in storage .
//id is required validation failed todo