本文整理汇总了PHP中Jam::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Jam::find方法的具体用法?PHP Jam::find怎么用?PHP Jam::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Jam
的用法示例。
在下文中一共展示了Jam::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _load_user
protected function _load_user($user)
{
if (!$user) {
return NULL;
}
return is_object($user) ? $user : Jam::find('test_user', $user);
}
示例2: get_jam
public function get_jam()
{
if (Request::ajax()) {
$jam = Input::get('jam');
$waktu = Jam::find($jam);
echo $waktu->dari_jam . "|" . $waktu->sampai_jam;
}
}
示例3: test_model_after_load
/**
* @covers Jam_Behavior_Promotable_Purchase::model_after_load
*/
public function test_model_after_load()
{
$purchase = Jam::find('purchase', 1);
$promo_code = Jam::find('promo_code', 2);
$purchase->promo_code = $promo_code;
$purchase->save();
$purchase = Jam::find('purchase', 1);
$this->assertEquals($promo_code->code, $purchase->promo_code_text);
}
示例4: test_load_loaded_user2
/**
* @covers ::load
*/
public function test_load_loaded_user2()
{
$user = Jam::find('user', 2);
Auth::instance()->force_login($user);
$result = Model_Visitor::load();
$this->assertSame($result->user, $user);
$this->assertTrue($result->loaded());
$this->assertNotEquals(1, $result->id());
}
示例5: model_after_check
/**
* If there is a new value in promo_code_text, try to load promo_code object.
* If the new value is NULL, remove it
* @param Model_Purchase $purchase
*/
public function model_after_check(Model_Purchase $purchase)
{
if ($purchase->changed('promo_code_text') and !$purchase->errors('promo_code_text')) {
if ($purchase->promo_code_text) {
$purchase->promo_code = Jam::find('promo_code', $purchase->promo_code_text);
} else {
$purchase->promo_code = NULL;
}
}
}
示例6: test_belongsto
/**
* @covers Kohana_Jam_Association_Materializedpath_Belongsto::model_after_save
*/
public function test_belongsto()
{
$two = Jam::find('category', 2);
$seven = Jam::find('category', 7);
$two->parent = $seven;
$two->save();
$result = Jam::all('category')->as_array('id', 'path');
$expected = array(1 => NULL, 2 => '1/3/6/7', 3 => '1', 4 => '1/3/6/7/2', 5 => '1/3/6/7/2', 6 => '1/3', 7 => '1/3/6', 8 => '1/3/6');
$this->assertEquals($expected, $result);
}
示例7: external_data_for
public function external_data_for(Model_Location $location)
{
$key = $this->generate_data_key($location);
$external_data = Jam::find('shipping_external_data', $key);
if (!$external_data) {
// TODO add proper external shipping API logic here
$external_data = Jam::build('shipping_external_data', array('key' => $key, 'price' => new Jam_Price(5.13, 'GBP'), 'delivery_time' => new Jam_Range(array(3, 5))));
$external_data->save();
}
return $external_data;
}
示例8: test_validate
public function test_validate()
{
$element = Jam::find('test_element', 1);
Jam::validator_rule('unique', array())->validate($element, 'name', $element->name);
$this->assertNotHasError($element, 'name', 'unique');
$element2 = Jam::find('test_element', 2);
Jam::validator_rule('unique', array())->validate($element2, 'url', $element2->url);
$this->assertHasError($element2, 'url', 'unique');
$element3 = Jam::find('test_element', 2);
Jam::validator_rule('unique', array('scope' => 'name'))->validate($element3, 'url', $element3->url);
$this->assertNotHasError($element3, 'url', 'unique');
}
示例9: test_model_before_check
/**
* @covers Jam_Behavior_Location_Parent::model_before_check
*/
public function test_model_before_check()
{
$france = Jam::find('location', 'France');
$address = Jam::build('address');
$address->city = Jam::build('location', array('name' => 'Paris'));
$address->country = $france;
$address->check();
$this->assertEquals($france, $address->city->parent);
$address->save();
$paris = Jam::find('location', 'Paris');
$this->assertEquals($france, $paris->parent);
}
示例10: test_has_promo_code
/**
* @covers Model_Promotion_Promocode::has_promo_code
*/
public function test_has_promo_code()
{
$promotion1 = Jam::find('promotion', 1);
$promotion2 = Jam::find('promotion', 2);
$promo_code1 = Jam::find('promo_code', 1);
$promo_code2 = Jam::find('promo_code', 2);
$promo_code3 = Jam::find('promo_code', 3);
$this->assertTrue($promotion1->has_promo_code($promo_code1));
$this->assertFalse($promotion1->has_promo_code($promo_code2));
$this->assertTrue($promotion2->has_promo_code($promo_code2));
$this->assertTrue($promotion2->has_promo_code($promo_code3));
}
示例11: build_user
public function build_user($data, $create = TRUE)
{
if ($this->logged_in() and !empty($data)) {
$user = Jam::build($this->_user_model);
if ($user->load_service_values($this, $data, $create) === FALSE) {
return FALSE;
}
$user->roles->add(Jam::find($this->_role_model, 'login'));
$user->set($this->_service_field, $this->service_uid());
return $user;
}
}
示例12: test_get
public function test_get()
{
$one = Jam::find('test_closurelist', 1);
$four = Jam::find('test_closurelist', 4);
$two = Jam::find('test_closurelist', 2);
// Check for Null Value changed
$this->assertNull($this->association->get($one, NULL, TRUE));
$this->assertEquals($one->id(), $this->association->get($four, NULL, FALSE)->id());
$this->assertEquals($two->id(), $this->association->get($four, 2, TRUE)->id());
$returned = $this->association->get($four, array('id' => 2, 'title' => 'new post title'), TRUE);
$this->assertEquals($two->id(), $returned->id());
$this->assertEquals('new post title', $returned->title);
}
示例13: action_remoteselect_template
public function action_remoteselect_template()
{
$params = $this->request->query();
if ($missing = array_diff(array('model', 'id', 'name', 'template'), array_keys($params))) {
throw new Kohana_Exception('You must provide :params query parameter', array(':params' => join(', ', $params)));
}
$params['item'] = Jam::find($params['model'], $params['id']);
if (!$params['item']) {
$this->response->body('');
} else {
$view = View::factory(Arr::get($params, 'template'), $params);
$this->response->body($view->render());
}
}
示例14: test_add_item
/**
* @covers Jam_Behavior_Shippable_Purchase::add_item
*/
public function test_add_item()
{
$purchase = Jam::find('purchase', 2);
$france = Jam::find('location', 'France');
$purchase->shipping_country($france);
$product = Jam::find('product', 2);
$perchase_item = Jam::build('purchase_item_product', array('reference' => $product));
$purchase->add_item($product->brand, $perchase_item);
$item = $purchase->brand_purchases[0]->shipping->items[0];
$this->assertInstanceOf('Model_Shipping_Item', $item);
$this->assertSame($france, $purchase->brand_purchases[0]->shipping->ship_to());
$this->assertSame($perchase_item, $item->purchase_item);
$this->assertInstanceOf('Model_Shipping_Group', $item->shipping_group);
}
示例15: test_collect_children
public function test_collect_children()
{
$model = Jam::find('test_blog', 1);
$collected = Jam_Behavior_Cascade::collect_models($model, array('test_posts'));
$this->assertEquals((string) $model, (string) $collected[0]);
foreach ($model->test_posts as $i => $post) {
$this->assertEquals((string) $post, (string) $collected[$i + 1]);
}
$collected = Jam_Behavior_Cascade::collect_models($model, array('test_posts' => array('test_author', 'test_tags', 'test_images')));
$expected = array($model, $model->test_posts[0], $model->test_posts[0]->test_author, $model->test_posts[0]->test_tags[0], $model->test_posts[0]->test_tags[1], $model->test_posts[0]->test_tags[2], $model->test_posts[0]->test_tags[3], $model->test_posts[0]->test_tags[4], $model->test_posts[0]->test_images[0]);
foreach ($expected as $i => $item) {
$this->assertEquals((string) $item, (string) $collected[$i], 'Collection item ' . $i . ' must be "' . $item . '"');
}
}