本文整理汇总了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);
});
}
示例2: boot
/**
* Overrides the models boot method.
*/
public static function boot()
{
parent::boot();
self::creating(function ($tag) {
$tag->slug = Str::slug($tag->name);
});
}
示例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()]);
});
}
示例4: boot
public static function boot()
{
parent::boot();
ProductReview::deleting(function ($productReview) {
File::delete($productReview->image);
});
}
示例5: boot
/**
* Boot the model.
*
* @return void
*/
public static function boot()
{
parent::boot();
static::created(function (self $preset) {
event(new PresetCreated($preset));
});
}
示例6: boot
/**
* The "booting" method of the model.
*
* @return void
*/
public static function boot()
{
parent::boot();
static::creating(function ($model) {
$model->setCreatedAt($model->freshTimestamp());
});
}
示例7: boot
public static function boot()
{
parent::boot();
Type::creating(function ($type) {
$type->company_id = $type->company_id ?: Auth::user()['company_id'];
});
}
示例8: boot
public static function boot()
{
parent::boot();
Webhook::creating(function ($results) {
Cache::forget('webhooks');
});
}
示例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();
});
}
示例10: boot
public static function boot()
{
parent::boot();
Event::deleting(function ($event) {
File::delete($event->image);
});
}
示例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;
}
});
}
示例12: boot
public static function boot()
{
parent::boot();
static::deleting(function ($user) {
$user->profile->delete();
});
}
示例13: boot
/**
* Listen for save event
*/
protected static function boot()
{
parent::boot();
static::saving(function ($model) {
self::setNullables($model);
});
}
示例14: boot
/**
* 删除文章时关联删除评论
*/
protected static function boot()
{
parent::boot();
static::deleting(function ($article) {
$article->comment()->delete();
});
}
示例15: boot
public static function boot()
{
parent::boot();
Widget::saved(function ($widget) {
\Cache::tags('widgets')->flush();
});
}