Exemple #1
0
 public function shipping_insist()
 {
     $self = $this;
     return Jam_Behavior_Paranoid::with_filter(Jam_Behavior_Paranoid::ALL, function () use($self) {
         return $self->get_insist('purchase_item')->get_insist('reference')->shipping();
     });
 }
 /**
  * If there is a promo_code object, load it into the promo_code_text
  * @param  Model_Purchase $purchase
  */
 public function model_after_load(Model_Purchase $purchase)
 {
     if ($purchase->promo_code_id) {
         $promo_code = Jam_Behavior_Paranoid::with_filter(Jam_Behavior_Paranoid::ALL, function () use($purchase) {
             return $purchase->promo_code;
         });
         $purchase->retrieved('promo_code_text', $promo_code->code);
     }
 }
Exemple #3
0
 /**
  * Perform the actual where modification when it is needed
  *
  * @param Jam_Query_Builder_Select    $builder
  */
 public function builder_paranoid_filter(Database_Query $builder)
 {
     $filter_type = $builder->params('paranoid_filter_type') ?: Jam_Behavior_Paranoid::filter();
     switch ($filter_type) {
         case Jam_Behavior_Paranoid::ALL:
             break;
         case Jam_Behavior_Paranoid::DELETED:
             $builder->where($this->_field, '=', TRUE);
             break;
         case Jam_Behavior_Paranoid::NORMAL:
         default:
             $builder->where($this->_field, '=', FALSE);
             break;
     }
 }
Exemple #4
0
 public function brand()
 {
     return Jam_Behavior_Paranoid::with_filter(Jam_Behavior_Paranoid::ALL, function () {
         return $this->brand;
     });
 }
Exemple #5
0
 public function test_with_filter()
 {
     $video = Jam::find('test_video', 1);
     $video->delete();
     $this->assertCount(3, Jam::all('test_video'));
     $result = Jam_Behavior_Paranoid::with_filter(Jam_Behavior_Paranoid::ALL, function () {
         return Jam::all('test_video')->count();
     });
     $this->assertEquals(5, $result);
     $result = Jam_Behavior_Paranoid::with_filter(Jam_Behavior_Paranoid::DELETED, function () {
         return Jam::all('test_video')->count();
     });
     $this->assertEquals(2, $result);
     $video = Jam_Behavior_Paranoid::with_filter(Jam_Behavior_Paranoid::ALL, function () {
         return Jam::all('test_video')->where(':primary_key', '=', 1)->first();
     });
     $video->restore_delete();
     $this->assertCount(4, Jam::all('test_video'));
     $result = Jam_Behavior_Paranoid::with_filter(Jam_Behavior_Paranoid::ALL, function () {
         return Jam::all('test_video')->count();
     });
     $this->assertEquals(5, $result);
     $result = Jam_Behavior_Paranoid::with_filter(Jam_Behavior_Paranoid::DELETED, function () {
         return Jam::all('test_video')->count();
     });
     $this->assertEquals(1, $result);
     $video->real_delete();
     $this->assertCount(3, Jam::all('test_video'));
     $result = Jam_Behavior_Paranoid::with_filter(Jam_Behavior_Paranoid::ALL, function () {
         return Jam::all('test_video')->count();
     });
     $this->assertEquals(4, $result);
     $result = Jam_Behavior_Paranoid::with_filter(Jam_Behavior_Paranoid::DELETED, function () {
         return Jam::all('test_video')->count();
     });
     $this->assertEquals(1, $result);
 }
Exemple #6
0
 /**
  * Get the reference even if it was deleted
  * @return Jam_Model
  */
 public function get_reference_paranoid()
 {
     $self = $this;
     return Jam_Behavior_Paranoid::with_filter(Jam_Behavior_Paranoid::ALL, function () use($self) {
         return $self->reference;
     });
 }
Exemple #7
0
 /**
  * Use paranoid for shipping group
  */
 public function shipping_group_insist()
 {
     $self = $this;
     return Jam_Behavior_Paranoid::with_filter(Jam_Behavior_Paranoid::ALL, function () use($self) {
         return $self->get_insist('shipping_group');
     });
 }