public static function boot() { parent::boot(); static::deleting(function ($medium) { \File::delete($medium->path); }); }
/** * Overrides the models boot method. */ public static function boot() { parent::boot(); self::creating(function ($tag) { $tag->slug = Str::slug($tag->name); }); }
public static function boot() { parent::boot(); static::creating(function ($model) { $model->effectivefrom = date('Y-m-d', strtotime($model->effectivefrom)); $model->effectiveto = date('Y-m-d', strtotime($model->effectiveto)); $model->createdby = Auth::user()->id; $model->createddate = date("Y-m-d H:i:s"); $model->modifiedby = Auth::user()->id; $model->modifieddate = date("Y-m-d H:i:s"); }); static::created(function ($model) { Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Add', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]); }); static::updating(function ($model) { $model->effectivefrom = date('Y-m-d', strtotime($model->effectivefrom)); $model->effectiveto = date('Y-m-d', strtotime($model->effectiveto)); $model->modifiedby = Auth::user()->id; $model->modifieddate = date("Y-m-d H:i:s"); }); static::updated(function ($model) { Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Update', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]); }); static::deleted(function ($model) { Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Delete', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]); }); }
public static function boot() { parent::boot(); ProductReview::deleting(function ($productReview) { File::delete($productReview->image); }); }
/** * Boot the model. * * @return void */ public static function boot() { parent::boot(); static::created(function (self $preset) { event(new PresetCreated($preset)); }); }
/** * The "booting" method of the model. * * @return void */ public static function boot() { parent::boot(); static::creating(function ($model) { $model->setCreatedAt($model->freshTimestamp()); }); }
public static function boot() { parent::boot(); Type::creating(function ($type) { $type->company_id = $type->company_id ?: Auth::user()['company_id']; }); }
public static function boot() { parent::boot(); Webhook::creating(function ($results) { Cache::forget('webhooks'); }); }
/** * Model bootstrap * * Ensure that the full_name field is filled even if it isn't initially provided. * * @return void */ protected static function boot() { parent::boot(); static::creating(function ($model) { return $model->fillFullName()->fillCompanyName(); }); }
public static function boot() { parent::boot(); Event::deleting(function ($event) { File::delete($event->image); }); }
public static function boot() { parent::boot(); static::creating(function ($model) { if ($model->status == null) { $model->status = static::CREATE; } if ($model->qty == null) { $model->qty = 1; } if ($model->location_id != null) { $location = Location::find($model->location_id, ['name']); if ($location) { $model->location_name = $location->name; } } }); static::created(function ($model) { }); static::updating(function ($model) { if ($model->qty == null) { $model->qty = 1; } }); }
public static function boot() { parent::boot(); static::deleting(function ($user) { $user->profile->delete(); }); }
/** * Listen for save event */ protected static function boot() { parent::boot(); static::saving(function ($model) { self::setNullables($model); }); }
/** * 删除文章时关联删除评论 */ protected static function boot() { parent::boot(); static::deleting(function ($article) { $article->comment()->delete(); }); }
public static function boot() { parent::boot(); Widget::saved(function ($widget) { \Cache::tags('widgets')->flush(); }); }
public static function boot() { parent::boot(); static::creating(function ($profile) { $profile->profile_pic = asset('img/avatar.png'); }); }
public static function boot() { parent::boot(); static::created(function ($topic) { SiteStatus::newReply(); }); }
public static function boot() { parent::boot(); CourseGalleryItem::deleting(function ($courseGalleryItem) { File::delete($courseGalleryItem->image); }); }
protected static function boot() { parent::boot(); static::creating(function ($model) { $model->{$model->getKeyName()} = Uuid::generate(4); }); }
public static function boot() { parent::boot(); static::saving(function ($instance) { $instance->code = strtoupper(str_random(6)); }); }
protected static function boot() { parent::boot(); static::creating(function ($adtype) { event(new AdtypeWillBeCreated($adtype)); }); static::created(function ($adtype) { event(new AdtypeWasCreated($adtype)); }); static::updating(function ($adtype) { event(new AdtypeWillBeUpdated($adtype)); }); static::updated(function ($adtype) { event(new AdtypeWasUpdated($adtype)); }); static::deleted(function ($adtype) { event(new AdtypeWasDeleted($adtype)); }); static::deleting(function ($adtype) { event(new AdtypeWillBeDeleted($adtype)); foreach ($adtype->ads as $ad) { $ad->forceDelete(); } $adtype->subscriptions()->detach(); $adtype->users()->detach(); }); }
public static function boot() { parent::boot(); Category::creating(function (Category $category) { $category->generateSlug(); }); }
/** * Listen for save event */ protected static function boot() { parent::boot(); static::saving(function ($model) { return $model->validate(); }); }
public static function boot() { parent::boot(); static::creating(function ($model) { $model->model = get_called_class(); }); }
/** * Boot the model. * * @return void */ public static function boot() { parent::boot(); static::creating(function ($user) { $user->token = str_random(30); }); }
/** * Override the boot method to bind model event listeners. * * @return void */ public static function boot() { parent::boot(); static::saved(function (Deployment $model) { event(new ModelChanged($model, 'deployment')); }); }
protected static function boot() { parent::boot(); static::deleting(function ($unit) { $unit->Tenants()->delete(); }); }
protected static function boot() { parent::boot(); static::deleting(function ($taskList) { $taskList->tasks()->delete(); }); }
public static function boot() { parent::boot(); static::deleted(function ($showtime) { $showtime->timeslots()->delete(); }); }
public static function boot() { parent::boot(); Tag::deleting(function ($tag) { $tag->stations()->detach(); }); }