Example #1
0
 protected static function boot()
 {
     parent::boot();
     static::deleting(function ($emoji) {
         $emoji->keywords()->delete();
     });
 }
 /**
  * The "booting" method of the model.
  *
  * @return void
  */
 public static function boot()
 {
     parent::boot();
     static::saving(function ($item) {
         $item->key = hash('sha512', microtime() . rand());
     });
 }
 /**
  * Model events.
  *
  * @return void
  */
 public static function boot()
 {
     parent::boot();
     static::deleted(function ($user) {
         $user->meta()->delete();
     });
 }
Example #4
0
 /**
  * 监听创建事件
  */
 public static function boot()
 {
     parent::boot();
     self::creating(function ($order) {
         $order->order_id = self::get_unique_id(self::$id_prefix);
         return true;
     });
 }
Example #5
0
 /**
  *
  */
 public static function boot()
 {
     parent::boot();
     self::deleting(function ($item) {
         $item->load(['values' => function ($q) {
             $q->delete();
         }]);
     });
 }
 protected static function boot()
 {
     parent::boot();
     static::deleting(function ($category) {
         foreach ($category->media as $block) {
             $block->delete();
         }
     });
 }
Example #7
0
 static function boot()
 {
     parent::boot();
     Static::observe(new TourSchedulePromoObserver());
     Static::observe(new TourScheduleVoucherObserver());
     Static::observe(new TourCalculationObserver());
     $env = env('ADS_ENGINE');
     if (str_is('on', $env)) {
         Static::observe(new TourAdsObserver());
     }
     Static::observe(new TourObserver());
 }
Example #8
0
 public static function boot()
 {
     parent::boot();
     static::deleting(function ($model) {
         foreach ($model->pictures as $picture) {
             $path = $picture->path;
             $thumbnail = $picture->thumbnail;
             if ($picture->delete()) {
                 File::delete(public_path($path));
                 File::delete(public_path($thumbnail));
             } else {
                 return false;
             }
         }
     });
 }
Example #9
0
 public static function boot()
 {
     parent::boot();
     self::deleting(function ($author) {
         if ($author->books->count() > 0) {
             $html = [];
             $html[0] = 'Penulis tidak bisa dihapus karena masih memiliki buku : ';
             foreach ($author->books as $key => $book) {
                 $key = $key + 1;
                 $html[$key] = "{$key}. {$book->title}";
             }
             Session::flash('pesan', $html);
             return false;
         }
     });
 }
Example #10
0
 public static function boot()
 {
     parent::boot();
     //delete associated file
     static::deleting(function ($photo) {
         try {
             $filepath = public_path('files/') . $photo->photo_url;
             if (file_exists($filepath)) {
                 unlink($filepath);
             }
         } catch (\Exception $e) {
             //some error while deleteing
             \Log::info('Error deleting: ' . $filepath);
             \Log::debug($e);
         }
     });
 }
 /**
  * Gallery model events.
  *
  * @return void
  */
 public static function boot()
 {
     parent::boot();
     static::saving(function ($gallery) {
         $gallery->filterMetaAttributes($gallery->attributes);
         $gallery->saveDefaultAttributes();
     });
     static::saved(function ($gallery) {
         if (empty($gallery::$metaAttributes)) {
             return;
         }
         $gallery->meta()->saveMany($gallery->createMetaList($gallery::$metaAttributes));
     });
     static::deleted(function ($gallery) {
         $gallery->meta()->delete();
     });
 }
Example #12
0
 public static function boot()
 {
     parent::boot();
     self::updating(function ($book) {
         $borrowed = DB::table('book_user')->where('book_id', $book->id)->where('returned', 0)->count();
         if ($book->amount < $borrowed) {
             Session::flash('pesan', "Jumlah buku {$book->title} harus >= {$borrowed}");
             return false;
         }
     });
     self::deleting(function ($book) {
         $borrowed = DB::table('book_user')->where('book_id', $book->id)->where('returned', 0)->count();
         if ($borrowed > 0) {
             Session::flash('pesan', "Buku {$book->title} masih dipinjam");
             return false;
         }
     });
 }
Example #13
0
 public static function boot()
 {
     parent::boot();
     static::deleting(function ($model) {
         foreach ($model->steps as $step) {
             $picture = $step->picture;
             if ($step->delete()) {
                 File::delete(public_path($picture));
                 return true;
             } else {
                 return false;
             }
         }
         foreach ($model->foods as $food) {
             if ($food->delete()) {
                 return true;
             } else {
                 return false;
             }
         }
     });
 }
Example #14
0
 public static function boot()
 {
     parent::boot();
     self::observe(new PageObserver());
 }
Example #15
0
 public static function boot()
 {
     parent::boot();
     // ShipmentLog::observe(new ShipmentLogObserver());
 }
Example #16
0
 /**
  * boot
  *
  */
 public static function boot()
 {
     parent::boot();
     // ShippingCost::observe(new ShippingCostObserver());
 }
Example #17
0
 /**
  * boot
  * observing model
  *
  */
 public static function boot()
 {
     parent::boot();
     // Queue::observe(new QueueObserver());
 }
Example #18
0
 /**
  * boot
  * observing model
  *
  */
 public static function boot()
 {
     parent::boot();
     // CalendarWork::observe(new CalendarWorkObserver());
 }
Example #19
0
 static function boot()
 {
     parent::boot();
     Static::observe(new TourPackageObserver());
 }
Example #20
0
 public static function boot()
 {
     parent::boot();
     // FollowWorkleave::observe(new FollowWorkleaveObserver());
 }
Example #21
0
 /**
  * boot
  * observing model
  *
  */
 public static function boot()
 {
     parent::boot();
     // FingerPrint::observe(new FingerPrintObserver());
 }
Example #22
0
 public static function boot()
 {
     parent::boot();
     // ClientTemplate::observe(new ClientTemplateObserver());
 }
Example #23
0
 static function boot()
 {
     parent::boot();
     Static::observe(new UserObserver());
 }
Example #24
0
 public static function boot()
 {
     parent::boot();
     // UserCampaign::observe(new UserCampaignObserver());
 }
Example #25
0
 static function boot()
 {
     parent::boot();
     // Static::observe(new TopUpLogObserver);
 }
Example #26
0
 /**
  * boot
  * observing model
  *
  */
 public static function boot()
 {
     parent::boot();
 }
Example #27
0
 public static function boot()
 {
     parent::boot();
     self::observe(new CategoryObserver());
 }
Example #28
0
 static function boot()
 {
     parent::boot();
     Static::observe(new IssuedVoucherObserver());
 }
Example #29
0
 public static function boot()
 {
     // there is some logic in this method, so don't forget this!
     parent::boot();
 }
Example #30
0
 static function boot()
 {
     parent::boot();
     Static::observe(new AddressObserver());
 }