当前位置: 首页>>代码示例>>PHP>>正文


PHP Model::boot方法代码示例

本文整理汇总了PHP中Illuminate\Database\Eloquent\Model::boot方法的典型用法代码示例。如果您正苦于以下问题:PHP Model::boot方法的具体用法?PHP Model::boot怎么用?PHP Model::boot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Illuminate\Database\Eloquent\Model的用法示例。


在下文中一共展示了Model::boot方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: boot

 public static function boot()
 {
     parent::boot();
     static::deleting(function ($medium) {
         \File::delete($medium->path);
     });
 }
开发者ID:wislem,项目名称:scaffenger,代码行数:7,代码来源:Media.php

示例2: boot

 /**
  * Overrides the models boot method.
  */
 public static function boot()
 {
     parent::boot();
     self::creating(function ($tag) {
         $tag->slug = Str::slug($tag->name);
     });
 }
开发者ID:xiaobailc,项目名称:Gitamin,代码行数:10,代码来源:Tag.php

示例3: boot

 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()]);
     });
 }
开发者ID:x-Zyte,项目名称:nissanhippro,代码行数:27,代码来源:CommissionSpecial.php

示例4: boot

 public static function boot()
 {
     parent::boot();
     ProductReview::deleting(function ($productReview) {
         File::delete($productReview->image);
     });
 }
开发者ID:TemRhythm,项目名称:priola-website,代码行数:7,代码来源:ProductReview.php

示例5: boot

 /**
  * Boot the model.
  *
  * @return void
  */
 public static function boot()
 {
     parent::boot();
     static::created(function (self $preset) {
         event(new PresetCreated($preset));
     });
 }
开发者ID:salpakan,项目名称:salpakan,代码行数:12,代码来源:Preset.php

示例6: boot

 /**
  * The "booting" method of the model.
  *
  * @return void
  */
 public static function boot()
 {
     parent::boot();
     static::creating(function ($model) {
         $model->setCreatedAt($model->freshTimestamp());
     });
 }
开发者ID:zvermafia,项目名称:lavoter,代码行数:12,代码来源:Uuid.php

示例7: boot

 public static function boot()
 {
     parent::boot();
     Type::creating(function ($type) {
         $type->company_id = $type->company_id ?: Auth::user()['company_id'];
     });
 }
开发者ID:alientronics,项目名称:fleetany-web,代码行数:7,代码来源:Type.php

示例8: boot

 public static function boot()
 {
     parent::boot();
     Webhook::creating(function ($results) {
         Cache::forget('webhooks');
     });
 }
开发者ID:alfred-nutile-inc,项目名称:webhooks,代码行数:7,代码来源:Webhook.php

示例9: boot

 /**
  * 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();
     });
 }
开发者ID:delatbabel,项目名称:contacts,代码行数:14,代码来源:Contact.php

示例10: boot

 public static function boot()
 {
     parent::boot();
     Event::deleting(function ($event) {
         File::delete($event->image);
     });
 }
开发者ID:TemRhythm,项目名称:priola-website,代码行数:7,代码来源:MassMediaNewsImage.php

示例11: boot

 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;
         }
     });
 }
开发者ID:vasitjuntong,项目名称:mixed,代码行数:25,代码来源:ReceiveItem.php

示例12: boot

 public static function boot()
 {
     parent::boot();
     static::deleting(function ($user) {
         $user->profile->delete();
     });
 }
开发者ID:michaeljoyner,项目名称:expeditionists,代码行数:7,代码来源:User.php

示例13: boot

 /**
  * Listen for save event
  */
 protected static function boot()
 {
     parent::boot();
     static::saving(function ($model) {
         self::setNullables($model);
     });
 }
开发者ID:spitzgoby,项目名称:dwa15_p4,代码行数:10,代码来源:NullableModel.php

示例14: boot

 /**
  * 删除文章时关联删除评论
  */
 protected static function boot()
 {
     parent::boot();
     static::deleting(function ($article) {
         $article->comment()->delete();
     });
 }
开发者ID:lanzhiwang,项目名称:laravel-blog,代码行数:10,代码来源:Article.php

示例15: boot

 public static function boot()
 {
     parent::boot();
     Widget::saved(function ($widget) {
         \Cache::tags('widgets')->flush();
     });
 }
开发者ID:matheusgomes17,项目名称:berrier,代码行数:7,代码来源:Widget.php


注:本文中的Illuminate\Database\Eloquent\Model::boot方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。