boot() protected static method

The "booting" method of the model.
protected static boot ( ) : void
return void
Esempio n. 1
0
 public static function boot()
 {
     parent::boot();
     static::deleting(function ($medium) {
         \File::delete($medium->path);
     });
 }
Esempio n. 2
0
 /**
  * Overrides the models boot method.
  */
 public static function boot()
 {
     parent::boot();
     self::creating(function ($tag) {
         $tag->slug = Str::slug($tag->name);
     });
 }
Esempio n. 3
0
 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()]);
     });
 }
Esempio n. 4
0
 public static function boot()
 {
     parent::boot();
     ProductReview::deleting(function ($productReview) {
         File::delete($productReview->image);
     });
 }
Esempio n. 5
0
 /**
  * Boot the model.
  *
  * @return void
  */
 public static function boot()
 {
     parent::boot();
     static::created(function (self $preset) {
         event(new PresetCreated($preset));
     });
 }
Esempio n. 6
0
 /**
  * The "booting" method of the model.
  *
  * @return void
  */
 public static function boot()
 {
     parent::boot();
     static::creating(function ($model) {
         $model->setCreatedAt($model->freshTimestamp());
     });
 }
Esempio n. 7
0
 public static function boot()
 {
     parent::boot();
     Type::creating(function ($type) {
         $type->company_id = $type->company_id ?: Auth::user()['company_id'];
     });
 }
Esempio n. 8
0
 public static function boot()
 {
     parent::boot();
     Webhook::creating(function ($results) {
         Cache::forget('webhooks');
     });
 }
Esempio n. 9
0
 /**
  * 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);
     });
 }
Esempio n. 11
0
 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;
         }
     });
 }
Esempio n. 12
0
 public static function boot()
 {
     parent::boot();
     static::deleting(function ($user) {
         $user->profile->delete();
     });
 }
Esempio n. 13
0
 /**
  * Listen for save event
  */
 protected static function boot()
 {
     parent::boot();
     static::saving(function ($model) {
         self::setNullables($model);
     });
 }
Esempio n. 14
0
 /**
  * 删除文章时关联删除评论
  */
 protected static function boot()
 {
     parent::boot();
     static::deleting(function ($article) {
         $article->comment()->delete();
     });
 }
Esempio n. 15
0
 public static function boot()
 {
     parent::boot();
     Widget::saved(function ($widget) {
         \Cache::tags('widgets')->flush();
     });
 }
Esempio n. 16
0
 public static function boot()
 {
     parent::boot();
     static::creating(function ($profile) {
         $profile->profile_pic = asset('img/avatar.png');
     });
 }
Esempio n. 17
0
 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);
     });
 }
Esempio n. 19
0
 protected static function boot()
 {
     parent::boot();
     static::creating(function ($model) {
         $model->{$model->getKeyName()} = Uuid::generate(4);
     });
 }
Esempio n. 20
0
 public static function boot()
 {
     parent::boot();
     static::saving(function ($instance) {
         $instance->code = strtoupper(str_random(6));
     });
 }
Esempio n. 21
0
File: Adtype.php Progetto: zedx/core
 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();
     });
 }
Esempio n. 22
0
 public static function boot()
 {
     parent::boot();
     Category::creating(function (Category $category) {
         $category->generateSlug();
     });
 }
Esempio n. 23
0
 /**
  * Listen for save event
  */
 protected static function boot()
 {
     parent::boot();
     static::saving(function ($model) {
         return $model->validate();
     });
 }
Esempio n. 24
0
 public static function boot()
 {
     parent::boot();
     static::creating(function ($model) {
         $model->model = get_called_class();
     });
 }
Esempio n. 25
0
 /**
  * Boot the model.
  *
  * @return void
  */
 public static function boot()
 {
     parent::boot();
     static::creating(function ($user) {
         $user->token = str_random(30);
     });
 }
Esempio n. 26
0
 /**
  * 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'));
     });
 }
Esempio n. 27
0
 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();
     });
 }
Esempio n. 29
0
 public static function boot()
 {
     parent::boot();
     static::deleted(function ($showtime) {
         $showtime->timeslots()->delete();
     });
 }
Esempio n. 30
0
 public static function boot()
 {
     parent::boot();
     Tag::deleting(function ($tag) {
         $tag->stations()->detach();
     });
 }