當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。