protected function beforeRender() { parent::beforeRender(); $user_id = $this->user->id; if ($this->user->isLoggedIn() and $user_id != NULL) { $css = $this->baseModel->getCss($user_id); $this->template->userCss = $css->style; } else { $this->template->userCss = 1; } }
public function c($rq = null) { $type = ['employee' => 1, 'agency' => 2, 'doctor' => 3]; $rq = rq(); $rq['senderid'] = uid(); $rq['sendername'] = username(); if (he_is('agency')) { $rq['org'] = sess('org'); } if (he_is('employee')) { $rq['org'] = sess('org'); } // return his_chara()[0]; $rq['sendertype'] = $type[his_chara()[0]]; if (his_chara()[0] == 'agency') { $rq['recipienttype'] = 1; $rq['recipientid'] = 1; $rq['recipientname'] = 'admin'; } elseif (his_chara()[0] == 'employee') { $rq['recipienttype'] = $type[$rq['recipienttype']]; } // 验证发信规则 $valid = $this->verify($rq); if (!$valid) { return ee(2); } $rq['sendtime'] = date("Y-m-d H:i:s"); return parent::c($rq); }
public function beforeValidate() { if (!$this->expires) { $this->expires = strtotime(Yii::$app->params['user']['reset_timeout']); } return parent::beforeValidate(); }
public function initialize() { parent::initialize(); $this->setSource($this->className()); $this->belongsTo('user_id', 'App\\Models\\User', 'id', ['alias' => 'User', 'foreignKey' => ['message' => 'The user_id does not exist on the User model']]); $this->belongsTo('provider_id', 'App\\Models\\Provider', 'id', ['alias' => 'Provider', 'foreignKey' => ['message' => 'The provider_id does not exist on the Provider model']]); }
public function initialize() { parent::initialize(); $this->setSource($this->className()); $this->hasManyToMany('id', 'App\\Models\\Relationships\\EventHasHashTag', 'hashTag_id', 'event_id', 'App\\Models\\Event', 'id', ['alias' => 'Events']); $this->hasManyToMany('id', 'App\\Models\\Relationships\\PhotoHasHashTag', 'hashTag_id', 'photo_id', 'App\\Models\\Photo', 'id', ['alias' => 'Photos']); }
public function initialize() { parent::initialize(); $this->setSource($this->className()); $this->belongsTo('period_id', 'App\\Models\\Period', 'id', ['alias' => 'Period', 'foreignKey' => ['message' => 'The period_id does not exist on the Period model']]); $this->hasOne('id', 'App\\Models\\Event', 'scheduling_id', ['alias' => 'Event']); }
public function __construct(array $attributes = []) { parent::__construct($attributes); if (app()->environment() === 'production') { $this->setConnection('mysql-hr'); } }
public function initialize() { parent::initialize(); $this->setSource($this->className()); $this->hasOne('id', 'App\\Models\\Event', 'guestList_id', ['alias' => 'Event']); $this->hasManyToMany('id', 'App\\Models\\Relationships\\Belong', 'guestList_id', 'user_id', 'App\\Models\\User', 'id', ['alias' => 'Users']); }
public function initialize() { parent::initialize(); $this->setSource($this->className()); $this->hasOne('id', 'App\\Models\\User', 'rrpp_id', ['alias' => 'User']); $this->hasMany('id', 'App\\Models\\Local', 'owner_id', ['alias' => 'Locals']); }
public function r() { if (Input::get('log')) { $this->eventFire('r', rq('id')); } return parent::r(); }
public function setAttribute($key, $value) { $isRememberTokenAttribute = $key == $this->getRememberTokenName(); if (!$isRememberTokenAttribute) { parent::setAttribute($key, $value); } }
protected static function boot() { parent::boot(); static::deleting(function ($image) { Storage::delete('uploads/m/' . $image->path . $image->key); }); }
/** * The "booting" method of the model. * * @return void */ public static function boot() { parent::boot(); static::saving(function ($item) { $item->key = $item->key; }); }
public function initialize() { parent::initialize(); $this->setSource($this->className()); $this->hasManyToMany('id', 'App\\Models\\Relationships\\EventHasPack', 'pack_id', 'event_id', 'App\\Models\\Event', 'id', ['alias' => 'Events']); $this->hasManyToMany('id', 'App\\Models\\Relationships\\PackHasProduct', 'pack_id', 'product_id', 'App\\Models\\Product', 'id', ['alias' => 'Products']); }
function __construct($init = []) { if (is_array($init)) { return parent::__construct($init); } else { $this->name = $init; } }
/** * 更新 */ public function u($rq = NULL) { $this->guarded = arr_except_vals($this->guarded, ['password']); if (!$rq) { $rq = rq(); } return parent::u($rq); }
public function initialize() { parent::initialize(); $this->setSource($this->className()); $this->belongsTo('event_id', 'App\\Models\\Event', 'id', ['alias' => 'Event', 'foreignKey' => ['message' => 'The event_id does not exist on the Event model']]); $this->hasManyToMany('id', 'App\\Models\\Relationships\\Appear', 'photo_id', 'user_id', 'App\\Models\\User', 'id', ['alias' => 'UsersAppearing']); $this->hasManyToMany('id', 'App\\Models\\Relationships\\PhotoHasHashTag', 'photo_id', 'hashTag_id', 'App\\Models\\HashTag', 'id', ['alias' => 'HashTags']); }
public function __construct() { parent::__construct(); $this->table = table_name($this->ins_name, 'i'); $this->createRule = ['email' => 'required|email', 'name' => 'required', 'phone' => 'required']; $this->updateRule = ['email' => 'required|email', 'name' => 'required', 'phone' => 'required']; $this->messages = ['phone.required' => '手机号码必填', 'email.required' => '电子邮箱必填', 'email.email' => '邮箱格式有误']; }
public function initialize() { parent::initialize(); $this->setSource($this->className()); $this->belongsTo('owner_id', 'App\\Models\\RRPP', 'id', ['alias' => 'Owner', 'foreignKey' => ['message' => 'The owner_id does not exist on the RRPP model']]); $this->hasMany('id', 'App\\Models\\Event', 'local_id', ['alias' => 'Events']); $this->hasManyToMany('id', 'App\\Models\\Relationships\\Follow', 'local_id', 'user_id', 'App\\Models\\User', 'id', ['alias' => 'Followers']); }
public function beforeSave($insert) { parent::beforeSave($insert); $this->url_code = \app\common\XUtils::shorturl($this->url); $this->description = \app\common\XUtils::ihtmlspecialchars($this->description); !$this->id && ($this->createtime = time()); $this->updatetime = time(); return true; }
public function __construct() { parent::__construct(); $this->table = table_name($this->ins_name, 'i'); // $this->createRule = [ // 'email' => 'required|email', // 'name' => 'required' // ]; }
/** * 更新 */ public function u($rq = null) { $this->guarded = arr_except_vals($this->guarded, ['password']); if (!$rq) { $rq = rq(); } if (isset($rq['password'])) { $rq['password'] = hash_password($rq['password']); } return parent::u($rq); }
/** * 入库前自动处理 */ public function beforeSave($insert) { parent::beforeSave($insert); if (trim($this->password)) { $this->password = md5($this->password); } if (!$this->id) { $this->create_time = time(); $this->last_login_time = time(); } return true; }
public function c($rq = NULL, $rules = NULL, $messages = NULL) { $rq = rq(); $new = parent::c($rq, $this->createRule); if ($new['status'] == 1) { // 设置 $query = $this->where('robot_id', $rq['robot_id']); $query->update(['recent' => 0]); $query->where('id', $new['d']['id'])->update(['recent' => 1]); } $new['rq'] = $rq; return $new; }
static function create($arr) { $arr['id'] = md5($arr['email']); if (static::count() == 0) { $arr['type'] = 0; static::first_user_tasks($arr); } else { $arr['type'] = 1; } $user = parent::create($arr); $user->export(); return $user; }
public function initialize() { parent::initialize(); $this->setSource($this->className()); $this->belongsTo('local_id', 'App\\Models\\Local', 'id', ['alias' => 'Local', 'foreignKey' => ['message' => 'The local_id does not exist on the Local model']]); $this->belongsTo('guestList_id', 'App\\Models\\GuestList', 'id', ['alias' => 'GuestList', 'foreignKey' => ['allowNulls' => true, 'message' => 'The guestList_id does not exist on the GuestList model']]); $this->belongsTo('scheduling_id', 'App\\Models\\Scheduling', 'id', ['alias' => 'Scheduling', 'foreignKey' => ['allowNulls' => true, 'message' => 'The scheduling_id does not exist on the Scheduling model']]); $this->hasManyToMany('id', 'App\\Models\\Relationships\\Attend', 'event_id', 'user_id', 'App\\Models\\User', 'id', ['alias' => 'Users']); $this->hasMany('id', 'App\\Models\\Photo', 'event_id', ['alias' => 'Photos']); $this->hasManyToMany('id', 'App\\Models\\Relationships\\EventHasHashTag', 'event_id', 'hashTag_id', 'App\\Models\\HashTag', 'id', ['alias' => 'HashTags']); $this->hasManyToMany('id', 'App\\Models\\Relationships\\EventHasMusicTag', 'event_id', 'musicTag_id', 'App\\Models\\MusicTag', 'id', ['alias' => 'MusicTags']); $this->hasManyToMany('id', 'App\\Models\\Relationships\\EventHasPack', 'event_id', 'pack_id', 'App\\Models\\Pack', 'id', ['alias' => 'Packs']); }
function __construct($init = []) { $this->_tables = []; if (is_array($init)) { parent::__construct($init); } else { $this->name = $init; } if (!$this->name) { $this->name = data_db_name(); } static::$list[$this->name] = $this; }
/** * @param string $id article_id or permalink * @return Article * @throws ModelNotFoundException */ public function findByIdentifier($id) { //if the id is a uuid, try that or fail. if (Uuid::isValid($id)) { return parent::findOrFail($id); } //otherwise attempt treat the id as a permalink and first try the model, then try the history try { return $this->where('permalink', '=', $id)->firstOrFail(); } catch (ModelNotFoundException $e) { //id or permalink not found, try permalink history return ArticlePermalink::findOrFail($id)->article; } }
public function u($rq = null) { // 验证 if (!rq('id')) { return ee(1); } $rules = $this->createRule; $rules['name'] = $rules['name'] . ',' . rq('id'); $validator = Validator::make($rq, $rules, $this->messages); if (!$validator->passes()) { return ee(2, $validator->errors()); } return parent::u($rq); }
public function beforeDelete() { if (parent::beforeDelete()) { if (OrderProducts::find()->where(['product_id' => $this->id])->exists()) { Yii::$app->session->setFlash('products_error', Yii::t('app', 'Cannot delete product <strong>{prod_name}</strong> because it was previosly ordered.', ['prod_name' => $this->getName()])); return false; } else { ProductLang::deleteAll(['product_id' => $this->id]); Yii::$app->session->setFlash('products_info', Yii::t('app', 'Product <strong>{prod_name}</strong> successfully deleted.', ['prod_name' => $this->getName()])); return true; } } else { return false; } }