Esempio n. 1
0
    public function validate($attributeNames = null, $clearErrors = true){

        if(parent::validate($attributeNames, $clearErrors)){
            Auction::infoLog('Model :: ' . self::className() . ' Has Successfully Validated ', $this->getAttributes());
            return true;
        }else{
            Auction::errorLog('Model record :: '. self::className() .' not validated ',$this->getErrors());
            return false;
        }
    }
    /**
     * Displays a single Dealers model.
     * @param integer $id
     * @return mixed
     */
    public function actionView($id)
    {
        $_model = Dealers::find()
                    ->with(['user0'])
                    ->where('id=:id',[':id' => $id])
                    ->one();

        if($_model === null){
            Auction::infoLog('No Dealer Found' , ['id' => $id]);
            throw new NotFoundHttpException('No Dealer Found');
        }
        return $this->render('view', [
            'model' => $_model
        ]);
    }
Esempio n. 3
0
    /**
     * @param $model
     * @return null|Mixed saved model primary key by setting it's attributes Validation to false
     */
    private function saveModel($model){
        $model->setAttributes($this->getAttributes(),false);

        if($model->save(false)){
            Auction::infoLog('Saving '. $model->className(), $model->getAttributes());
            return $model->primaryKey;
        }
        else {
            return null;
        }
    }
Esempio n. 4
0
    public function update($runValidation = true, $attributeNames = null){
        $this->image = UploadedFile::getInstance($this->user0, 'profile_pic');

        if(!parent::validate())
            return false;

        if($this->image instanceof  UploadedFile){

            if(!getimagesize($this->image->tempName)){
                $this->addError('image','Please Upload a valid Image');
                return false;
            }

            Auction::info('Image Upload Event Triggered');
            $this->trigger(Events::UPLOAD_IMAGE);

            parent::update(false);
            $this->user0->profile_pic = $this->image;
        }
        else{
            $this->user0->profile_pic = $this->user0->oldAttributes['profile_pic'];
        }

        if($this->user0->save(false)) {
            Auction::info('Dealer is successsfully Updated');
            return true;
        }else{
            Auction::infoLog('Dealer is not updated Due to following validation Errors',$this->user0->getErrors());
            return false;
        }
    }
Esempio n. 5
0
    /**
     * Company Added By Dealer
     * then status => 1
     *
     * is_active need to change by company/company User
     */
    public function addedByDealer($id){

        $_model = DealerCompany::find()->where([
            'company' => $id,
            'dealer' => Auction::dealer()
        ])->one();

        if($_model === null){

            $_model = new DealerCompany();
            $_model->company = $id;
            $_model->dealer = Auction::dealer();
            $_model->is_active = DatabaseHelper::IN_ACTIVE;
            $_model->status = DatabaseHelper::ACTIVE;
            $_model->mode = DatabaseHelper::DEALER_APPROVE_APPROVAL_REQUIRED;

            Auction::infoLog('Creating A new Dealer Company Since No Record of DealerCompany of',['company' => $id ,'dealer' => Auction::dealer()]);

        }else{
            switch ($_model->status){

                case DatabaseHelper::ACTIVE :
                    $_model->status = DatabaseHelper::IN_ACTIVE;
                    break;

                case DatabaseHelper::IN_ACTIVE :
                    $_model->status = DatabaseHelper::ACTIVE;
                    break;
            }
            Auction::infoLog('Updating Dealer Company Status',['company' => $id ,'dealer' => Auction::dealer()]);
        }

        return $_model->save();
    }