boot() protected static method

The "booting" method of the model.
protected static boot ( ) : void
return void
コード例 #1
0
ファイル: Media.php プロジェクト: wislem/scaffenger
 public static function boot()
 {
     parent::boot();
     static::deleting(function ($medium) {
         \File::delete($medium->path);
     });
 }
コード例 #2
0
ファイル: Tag.php プロジェクト: xiaobailc/Gitamin
 /**
  * Overrides the models boot method.
  */
 public static function boot()
 {
     parent::boot();
     self::creating(function ($tag) {
         $tag->slug = Str::slug($tag->name);
     });
 }
コード例 #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()]);
     });
 }
コード例 #4
0
 public static function boot()
 {
     parent::boot();
     ProductReview::deleting(function ($productReview) {
         File::delete($productReview->image);
     });
 }
コード例 #5
0
ファイル: Preset.php プロジェクト: salpakan/salpakan
 /**
  * Boot the model.
  *
  * @return void
  */
 public static function boot()
 {
     parent::boot();
     static::created(function (self $preset) {
         event(new PresetCreated($preset));
     });
 }
コード例 #6
0
ファイル: Uuid.php プロジェクト: zvermafia/lavoter
 /**
  * The "booting" method of the model.
  *
  * @return void
  */
 public static function boot()
 {
     parent::boot();
     static::creating(function ($model) {
         $model->setCreatedAt($model->freshTimestamp());
     });
 }
コード例 #7
0
ファイル: Type.php プロジェクト: alientronics/fleetany-web
 public static function boot()
 {
     parent::boot();
     Type::creating(function ($type) {
         $type->company_id = $type->company_id ?: Auth::user()['company_id'];
     });
 }
コード例 #8
0
 public static function boot()
 {
     parent::boot();
     Webhook::creating(function ($results) {
         Cache::forget('webhooks');
     });
 }
コード例 #9
0
ファイル: Contact.php プロジェクト: delatbabel/contacts
 /**
  * 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();
     });
 }
コード例 #10
0
 public static function boot()
 {
     parent::boot();
     Event::deleting(function ($event) {
         File::delete($event->image);
     });
 }
コード例 #11
0
ファイル: ReceiveItem.php プロジェクト: vasitjuntong/mixed
 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;
         }
     });
 }
コード例 #12
0
ファイル: User.php プロジェクト: michaeljoyner/expeditionists
 public static function boot()
 {
     parent::boot();
     static::deleting(function ($user) {
         $user->profile->delete();
     });
 }
コード例 #13
0
ファイル: NullableModel.php プロジェクト: spitzgoby/dwa15_p4
 /**
  * Listen for save event
  */
 protected static function boot()
 {
     parent::boot();
     static::saving(function ($model) {
         self::setNullables($model);
     });
 }
コード例 #14
0
ファイル: Article.php プロジェクト: lanzhiwang/laravel-blog
 /**
  * 删除文章时关联删除评论
  */
 protected static function boot()
 {
     parent::boot();
     static::deleting(function ($article) {
         $article->comment()->delete();
     });
 }
コード例 #15
0
ファイル: Widget.php プロジェクト: matheusgomes17/berrier
 public static function boot()
 {
     parent::boot();
     Widget::saved(function ($widget) {
         \Cache::tags('widgets')->flush();
     });
 }
コード例 #16
0
ファイル: Profile.php プロジェクト: xenxa/royalflushnetwork
 public static function boot()
 {
     parent::boot();
     static::creating(function ($profile) {
         $profile->profile_pic = asset('img/avatar.png');
     });
 }
コード例 #17
0
 public static function boot()
 {
     parent::boot();
     static::created(function ($topic) {
         SiteStatus::newReply();
     });
 }
コード例 #18
0
 public static function boot()
 {
     parent::boot();
     CourseGalleryItem::deleting(function ($courseGalleryItem) {
         File::delete($courseGalleryItem->image);
     });
 }
コード例 #19
0
ファイル: Type.php プロジェクト: esbenp/sldashboard
 protected static function boot()
 {
     parent::boot();
     static::creating(function ($model) {
         $model->{$model->getKeyName()} = Uuid::generate(4);
     });
 }
コード例 #20
0
ファイル: Team.php プロジェクト: axsauze/SDHacks
 public static function boot()
 {
     parent::boot();
     static::saving(function ($instance) {
         $instance->code = strtoupper(str_random(6));
     });
 }
コード例 #21
0
ファイル: Adtype.php プロジェクト: 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();
     });
 }
コード例 #22
0
ファイル: Category.php プロジェクト: amteknologi/e-commerce
 public static function boot()
 {
     parent::boot();
     Category::creating(function (Category $category) {
         $category->generateSlug();
     });
 }
コード例 #23
0
ファイル: Model.php プロジェクト: doberbeatz/backend
 /**
  * Listen for save event
  */
 protected static function boot()
 {
     parent::boot();
     static::saving(function ($model) {
         return $model->validate();
     });
 }
コード例 #24
0
ファイル: Feedback.php プロジェクト: vnsource/core
 public static function boot()
 {
     parent::boot();
     static::creating(function ($model) {
         $model->model = get_called_class();
     });
 }
コード例 #25
0
ファイル: User.php プロジェクト: paihz/instaX-project
 /**
  * Boot the model.
  *
  * @return void
  */
 public static function boot()
 {
     parent::boot();
     static::creating(function ($user) {
         $user->token = str_random(30);
     });
 }
コード例 #26
0
ファイル: Deployment.php プロジェクト: BlueBayTravel/deployer
 /**
  * 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'));
     });
 }
コード例 #27
0
ファイル: Unit.php プロジェクト: bgaeddert/PropMan
 protected static function boot()
 {
     parent::boot();
     static::deleting(function ($unit) {
         $unit->Tenants()->delete();
     });
 }
コード例 #28
0
 protected static function boot()
 {
     parent::boot();
     static::deleting(function ($taskList) {
         $taskList->tasks()->delete();
     });
 }
コード例 #29
0
ファイル: Showtime.php プロジェクト: kbirmhrjn/movie-notifier
 public static function boot()
 {
     parent::boot();
     static::deleted(function ($showtime) {
         $showtime->timeslots()->delete();
     });
 }
コード例 #30
0
ファイル: Tag.php プロジェクト: ZeljkoDzafic/AeroMeter
 public static function boot()
 {
     parent::boot();
     Tag::deleting(function ($tag) {
         $tag->stations()->detach();
     });
 }