本文整理汇总了PHP中Rule::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Rule::create方法的具体用法?PHP Rule::create怎么用?PHP Rule::create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rule
的用法示例。
在下文中一共展示了Rule::create方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: up
/**
* Make changes to the database.
*
* @return void
*/
public function up()
{
Schema::create('users', function ($table) {
$table->increments('id');
$table->string('email')->unique();
$table->string('password');
$table->string('name');
$table->integer('age');
$table->timestamps();
});
User::create(array('id' => 1, 'email' => 'admin@domain.com', 'password' => Hash::make('test'), 'name' => 'I am Administrator', 'age' => 40));
User::create(array('id' => 2, 'email' => 'staff@domain.com', 'password' => Hash::make('test'), 'name' => 'I am Staff', 'age' => 30));
User::create(array('id' => 3, 'email' => 'member@domain.com', 'password' => Hash::make('test'), 'name' => 'I am Member', 'age' => 25));
User::create(array('id' => 4, 'email' => 'mutant@domain.com', 'password' => Hash::make('test'), 'name' => 'I am Member and Staff', 'age' => 17));
Schema::create('roles', function ($table) {
$table->increments('id');
$table->string('name');
$table->timestamps();
});
Role::create(array('id' => 1, 'name' => 'Admin'));
Role::create(array('id' => 2, 'name' => 'Staff'));
Role::create(array('id' => 3, 'name' => 'Member'));
Schema::create('rules', function ($table) {
$table->increments('id');
$table->string('group');
$table->string('action');
$table->string('description');
$table->timestamps();
});
Rule::create(array('id' => 1, 'group' => 'demo', 'action' => '*', 'description' => 'Can access Demo all actions.'));
Rule::create(array('id' => 2, 'group' => 'demo', 'action' => 'view', 'description' => 'Can view Demo.'));
Rule::create(array('id' => 3, 'group' => 'demo', 'action' => 'create', 'description' => 'Can create Demo.'));
Rule::create(array('id' => 4, 'group' => 'demo', 'action' => 'edit', 'description' => 'Can edit Demo.'));
Rule::create(array('id' => 5, 'group' => 'demo', 'action' => 'revise', 'description' => 'Can revise Demo.'));
Rule::create(array('id' => 6, 'group' => 'demo', 'action' => 'publish', 'description' => 'Can publish Demo.'));
Rule::create(array('id' => 7, 'group' => 'demo', 'action' => 'delete', 'description' => 'Can delete Demo.'));
Schema::create('role_rule', function ($table) {
$table->increments('id');
$table->integer('role_id');
$table->integer('rule_id');
$table->timestamps();
});
Role::find(1)->rules()->sync(array(1));
Role::find(2)->rules()->sync(array(2, 5, 6, 7));
Role::find(3)->rules()->sync(array(2, 4, 3));
Schema::create('role_user', function ($table) {
$table->increments('id');
$table->integer('user_id');
$table->integer('role_id');
$table->timestamps();
});
User::find(1)->roles()->attach(1);
User::find(2)->roles()->attach(2);
User::find(3)->roles()->attach(3);
User::find(4)->roles()->sync(array(2, 3));
}
示例2: doExecute
function doExecute()
{
$rule = Rule::create($this->get('rule'));
if ($rule->group === '') {
$rule->group = null;
}
$this->beforeSave($rule);
$ret = $rule->save($rule);
if ($ret) {
return $this->success($ret);
} else {
return $this->error(ErrorInfo::ERROR_NO_DB_OPERATION_ERROR, 'modify failed');
}
}
示例3: saveRule
private function saveRule()
{
$data = array('url' => '/add', 'res' => array('errno' => '0', 'data' => array('name' => 'hehe')));
$rc1 = new RuleCondition();
$rc1->condId = ObjectUtil::guid();
$rc1->logicType = RuleCondition::LOGIC_TYPE_AND;
$rce1 = new RuleConditionExpression();
$rce1->contextType = RuleConditionExpressionOperand::CONTEXT_TYPE_REQUEST;
$rce1->key = 'name';
$rce1->value = 'Lily';
$rce1->operator = RuleConditionExpression::OPERATOR_EQUAL;
$rce2 = new RuleConditionExpression();
$rce2->contextType = RuleConditionExpressionOperand::CONTEXT_TYPE_REQUEST;
$rce2->key = 'age';
$rce2->value = 10;
$rce2->operator = RuleConditionExpression::OPERATOR_GRATER;
$rc1->expressions = array($rce1, $rce2);
$rc2 = new RuleCondition();
$rc2->condId = ObjectUtil::guid();
$rc2->logicType = RuleCondition::LOGIC_TYPE_OR;
$rce3 = new RuleConditionExpression();
$rce3->contextType = RuleConditionExpressionOperand::CONTEXT_TYPE_HEADER;
$rce3->key = 'WITH_XML_HTTP_REQUEST';
$rce3->operator = RuleConditionExpression::OPERATOR_IS_SET;
$rce4 = new RuleConditionExpression();
$rce4->contextType = RuleConditionExpressionOperand::CONTEXT_TYPE_REQUEST;
$rce4->key = 'agent';
$rce4->value = "MSIE";
$rce4->operator = RuleConditionExpression::OPERATOR_NOT_CONTAIN;
$rc2->expressions = array($rce3, $rce4);
$data['conditions'] = array($rc1, $rc2);
$rule = Rule::create($data);
// return $this->success($rule);
$ret = $rule->save();
if ($ret) {
return $this->success($ret);
} else {
return $this->error(ErrorInfo::ERROR_NO_DB_OPERATION_ERROR, 'save failed');
}
}
示例4: run
public function run()
{
Eloquent::unguard();
$formular_insta = Formular::create(array('name' => 'insta'));
$insta = Inputrule::create(array('formular_id' => $formular_insta->id, 'name' => 'installNr'));
$rules = Rule::create(array('inputrule_id' => $insta->id, 'rule' => 'required'));
$rules = Rule::create(array('inputrule_id' => $insta->id, 'rule' => 'digits:8'));
$insta = Inputrule::create(array('formular_id' => $formular_insta->id, 'name' => 'firmenName'));
$rules = Rule::create(array('inputrule_id' => $insta->id, 'rule' => 'required'));
$rules = Rule::create(array('inputrule_id' => $insta->id, 'rule' => 'max:40'));
$insta = Inputrule::create(array('formular_id' => $formular_insta->id, 'name' => 'ort'));
$rules = Rule::create(array('inputrule_id' => $insta->id, 'rule' => 'required'));
$rules = Rule::create(array('inputrule_id' => $insta->id, 'rule' => 'max:40'));
$insta = Inputrule::create(array('formular_id' => $formular_insta->id, 'name' => 'strasse'));
$rules = Rule::create(array('inputrule_id' => $insta->id, 'rule' => 'required'));
$rules = Rule::create(array('inputrule_id' => $insta->id, 'rule' => 'max:40'));
$insta = Inputrule::create(array('formular_id' => $formular_insta->id, 'name' => 'strNr'));
$rules = Rule::create(array('inputrule_id' => $insta->id, 'rule' => 'required'));
$rules = Rule::create(array('inputrule_id' => $insta->id, 'rule' => 'regex:/^\\d+\\s*[a-zA-Z]*$/'));
$rules = Rule::create(array('inputrule_id' => $insta->id, 'rule' => 'max:10'));
$insta = Inputrule::create(array('formular_id' => $formular_insta->id, 'name' => 'plz'));
$rules = Rule::create(array('inputrule_id' => $insta->id, 'rule' => 'required'));
$rules = Rule::create(array('inputrule_id' => $insta->id, 'rule' => 'digits:5'));
$insta = Inputrule::create(array('formular_id' => $formular_insta->id, 'name' => 'telefon'));
$rules = Rule::create(array('inputrule_id' => $insta->id, 'rule' => 'alpha_dash'));
$rules = Rule::create(array('inputrule_id' => $insta->id, 'rule' => 'max:30'));
$insta = Inputrule::create(array('formular_id' => $formular_insta->id, 'name' => 'fax'));
$rules = Rule::create(array('inputrule_id' => $insta->id, 'rule' => 'alpha_dash'));
$rules = Rule::create(array('inputrule_id' => $insta->id, 'rule' => 'max:30'));
$insta = Inputrule::create(array('formular_id' => $formular_insta->id, 'name' => 'vorname'));
$rules = Rule::create(array('inputrule_id' => $insta->id, 'rule' => 'required'));
$rules = Rule::create(array('inputrule_id' => $insta->id, 'rule' => 'alpha_dash'));
$rules = Rule::create(array('inputrule_id' => $insta->id, 'rule' => 'max:40'));
$insta = Inputrule::create(array('formular_id' => $formular_insta->id, 'name' => 'nachname'));
$rules = Rule::create(array('inputrule_id' => $insta->id, 'rule' => 'required'));
$rules = Rule::create(array('inputrule_id' => $insta->id, 'rule' => 'alpha_dash'));
$rules = Rule::create(array('inputrule_id' => $insta->id, 'rule' => 'max:40'));
//AnschlussFormular
$formular_ansch = Formular::create(array('name' => 'ansch'));
//Kundendaten
$ansch = Inputrule::create(array('formular_id' => $formular_ansch->id, 'name' => 'KdnFirmenNam'));
$rules = Rule::create(array('inputrule_id' => $ansch->id, 'rule' => 'required'));
$rules = Rule::create(array('inputrule_id' => $ansch->id, 'rule' => 'max:40'));
$ansch = Inputrule::create(array('formular_id' => $formular_ansch->id, 'name' => 'KdnVorNam'));
$rules = Rule::create(array('inputrule_id' => $ansch->id, 'rule' => 'required'));
$rules = Rule::create(array('inputrule_id' => $ansch->id, 'rule' => 'max:40'));
$ansch = Inputrule::create(array('formular_id' => $formular_ansch->id, 'name' => 'KdnNachNam'));
$rules = Rule::create(array('inputrule_id' => $ansch->id, 'rule' => 'required'));
$rules = Rule::create(array('inputrule_id' => $ansch->id, 'rule' => 'max:40'));
$ansch = Inputrule::create(array('formular_id' => $formular_ansch->id, 'name' => 'KdnPlz'));
$rules = Rule::create(array('inputrule_id' => $ansch->id, 'rule' => 'required'));
$rules = Rule::create(array('inputrule_id' => $ansch->id, 'rule' => 'digits:5'));
$ansch = Inputrule::create(array('formular_id' => $formular_ansch->id, 'name' => 'KdnOrt'));
$rules = Rule::create(array('inputrule_id' => $ansch->id, 'rule' => 'required'));
$rules = Rule::create(array('inputrule_id' => $ansch->id, 'rule' => 'max:40'));
$ansch = Inputrule::create(array('formular_id' => $formular_ansch->id, 'name' => 'KdnStr'));
$rules = Rule::create(array('inputrule_id' => $ansch->id, 'rule' => 'required'));
$rules = Rule::create(array('inputrule_id' => $ansch->id, 'rule' => 'max:40'));
$ansch = Inputrule::create(array('formular_id' => $formular_ansch->id, 'name' => 'KdnHausNr'));
$rules = Rule::create(array('inputrule_id' => $ansch->id, 'rule' => 'required'));
$rules = Rule::create(array('inputrule_id' => $ansch->id, 'rule' => 'regex:/^\\d+\\s*[a-zA-Z]*$/'));
$rules = Rule::create(array('inputrule_id' => $ansch->id, 'rule' => 'max:10'));
$ansch = Inputrule::create(array('formular_id' => $formular_ansch->id, 'name' => 'KdnTel'));
$rules = Rule::create(array('inputrule_id' => $ansch->id, 'rule' => 'alpha_dash'));
$rules = Rule::create(array('inputrule_id' => $ansch->id, 'rule' => 'max:30'));
//Kundendaten_eigentuemer
$ansch = Inputrule::create(array('formular_id' => $formular_ansch->id, 'name' => 'EigtFirmenNam'));
$rules = Rule::create(array('inputrule_id' => $ansch->id, 'rule' => 'required'));
$rules = Rule::create(array('inputrule_id' => $ansch->id, 'rule' => 'max:40'));
$ansch = Inputrule::create(array('formular_id' => $formular_ansch->id, 'name' => 'EigtVorNam'));
$rules = Rule::create(array('inputrule_id' => $ansch->id, 'rule' => 'required'));
$rules = Rule::create(array('inputrule_id' => $ansch->id, 'rule' => 'max:40'));
$ansch = Inputrule::create(array('formular_id' => $formular_ansch->id, 'name' => 'EigtNachNam'));
$rules = Rule::create(array('inputrule_id' => $ansch->id, 'rule' => 'required'));
$rules = Rule::create(array('inputrule_id' => $ansch->id, 'rule' => 'max:40'));
$ansch = Inputrule::create(array('formular_id' => $formular_ansch->id, 'name' => 'EigtPlz'));
$rules = Rule::create(array('inputrule_id' => $ansch->id, 'rule' => 'required'));
$rules = Rule::create(array('inputrule_id' => $ansch->id, 'rule' => 'digits:5'));
$ansch = Inputrule::create(array('formular_id' => $formular_ansch->id, 'name' => 'EigtOrt'));
$rules = Rule::create(array('inputrule_id' => $ansch->id, 'rule' => 'required'));
$rules = Rule::create(array('inputrule_id' => $ansch->id, 'rule' => 'max:40'));
$ansch = Inputrule::create(array('formular_id' => $formular_ansch->id, 'name' => 'EigtStr'));
$rules = Rule::create(array('inputrule_id' => $ansch->id, 'rule' => 'required'));
$rules = Rule::create(array('inputrule_id' => $ansch->id, 'rule' => 'max:40'));
$ansch = Inputrule::create(array('formular_id' => $formular_ansch->id, 'name' => 'EigtHausNr'));
$rules = Rule::create(array('inputrule_id' => $ansch->id, 'rule' => 'required'));
$rules = Rule::create(array('inputrule_id' => $ansch->id, 'rule' => 'regex:/^\\d+\\s*[a-zA-Z]*$/'));
$rules = Rule::create(array('inputrule_id' => $ansch->id, 'rule' => 'max:10'));
$ansch = Inputrule::create(array('formular_id' => $formular_ansch->id, 'name' => 'EigtTel'));
$rules = Rule::create(array('inputrule_id' => $ansch->id, 'rule' => 'alpha_dash'));
$rules = Rule::create(array('inputrule_id' => $ansch->id, 'rule' => 'max:30'));
// objektdaten
$ansch = Inputrule::create(array('formular_id' => $formular_ansch->id, 'name' => 'bedarfsart'));
$rules = Rule::create(array('inputrule_id' => $ansch->id, 'rule' => 'required'));
$rules = Rule::create(array('inputrule_id' => $ansch->id, 'rule' => 'digits:1'));
$ansch = Inputrule::create(array('formular_id' => $formular_ansch->id, 'name' => 'ObjAdrPlz'));
$rules = Rule::create(array('inputrule_id' => $ansch->id, 'rule' => 'required'));
$rules = Rule::create(array('inputrule_id' => $ansch->id, 'rule' => 'digits:5'));
$ansch = Inputrule::create(array('formular_id' => $formular_ansch->id, 'name' => 'ObjAdrOrt'));
$rules = Rule::create(array('inputrule_id' => $ansch->id, 'rule' => 'required'));
//.........这里部分代码省略.........
示例5: testCreateThrowsException
public function testCreateThrowsException()
{
$this->setExpectedException('Exception', 'All Rule class extensions should implement the Rule::create() method');
Rule::create();
}
示例6: create_base_rules
/**
* @param $fields
* @return mixed
* @throws Sentry\SentryException
*/
public function create_base_rules($fields)
{
$rule = Rule::create($fields);
if ($rule === false) {
throw new Sentry\SentryException();
}
return $rule->id;
}