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(); }); }
/** * 监听创建事件 */ public static function boot() { parent::boot(); self::creating(function ($order) { $order->order_id = self::get_unique_id(self::$id_prefix); return true; }); }
/** * */ 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(); } }); }
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()); }
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; } } }); }
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; } }); }
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(); }); }
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; } }); }
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; } } }); }
public static function boot() { parent::boot(); self::observe(new PageObserver()); }
public static function boot() { parent::boot(); // ShipmentLog::observe(new ShipmentLogObserver()); }
/** * boot * */ public static function boot() { parent::boot(); // ShippingCost::observe(new ShippingCostObserver()); }
/** * boot * observing model * */ public static function boot() { parent::boot(); // Queue::observe(new QueueObserver()); }
/** * boot * observing model * */ public static function boot() { parent::boot(); // CalendarWork::observe(new CalendarWorkObserver()); }
static function boot() { parent::boot(); Static::observe(new TourPackageObserver()); }
public static function boot() { parent::boot(); // FollowWorkleave::observe(new FollowWorkleaveObserver()); }
/** * boot * observing model * */ public static function boot() { parent::boot(); // FingerPrint::observe(new FingerPrintObserver()); }
public static function boot() { parent::boot(); // ClientTemplate::observe(new ClientTemplateObserver()); }
static function boot() { parent::boot(); Static::observe(new UserObserver()); }
public static function boot() { parent::boot(); // UserCampaign::observe(new UserCampaignObserver()); }
static function boot() { parent::boot(); // Static::observe(new TopUpLogObserver); }
/** * boot * observing model * */ public static function boot() { parent::boot(); }
public static function boot() { parent::boot(); self::observe(new CategoryObserver()); }
static function boot() { parent::boot(); Static::observe(new IssuedVoucherObserver()); }
public static function boot() { // there is some logic in this method, so don't forget this! parent::boot(); }
static function boot() { parent::boot(); Static::observe(new AddressObserver()); }