本文整理汇总了PHP中app\models\BaseModel::boot方法的典型用法代码示例。如果您正苦于以下问题:PHP BaseModel::boot方法的具体用法?PHP BaseModel::boot怎么用?PHP BaseModel::boot使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\BaseModel
的用法示例。
在下文中一共展示了BaseModel::boot方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: boot
/**
* The "booting" method of the model.
*
* @return void
*/
public static function boot()
{
parent::boot();
static::saving(function ($item) {
$item->key = $item->key;
});
}
示例2: boot
protected static function boot()
{
parent::boot();
static::deleting(function ($image) {
Storage::delete('uploads/m/' . $image->path . $image->key);
});
}
示例3: boot
public static function boot()
{
parent::boot();
static::created(function ($course) {
// 2016-09-01:应教务处要求添加公体选课统计,修改选课统计方式
if ($isPubSport = Helper::isCourseType($course->kcxh, 'TB14')) {
$count = Count::whereKcxh($course->kcxh)->first();
} else {
$count = Count::whereKcxh($course->kcxh)->whereZy($course->zy)->first();
}
if (count($count)) {
$count->rs += 1;
} else {
$count = new Count();
$count->kcxh = $course->kcxh;
$count->zy = $isPubSport ? '' : $course->zy;
$count->rs = 1;
}
$count->save();
$log = new Slog();
$log->kcxh = $course->kcxh;
$log->ip = request()->ip();
$log->czlx = 'insert';
$log->save();
});
static::deleted(function ($course) {
// 2016-09-01:应教务处要求添加公体选课统计,修改选课统计方式
if ($isPubSport = Helper::isCourseType($course->kcxh, 'TB14')) {
$count = Count::whereKcxh($course->kcxh)->first();
} else {
$count = Count::whereKcxh($course->kcxh)->whereZy($course->zy)->first();
}
if (count($count)) {
$count->rs -= 1;
} else {
$count = new Count();
$count->kcxh = $course->kcxh;
$count->zy = $isPubSport ? '' : $course->zy;
$count->rs = 0;
}
$count->save();
$log = new Slog();
$log->kcxh = $course->kcxh;
$log->ip = request()->ip();
$log->czlx = 'delete';
$log->save();
});
}
示例4: boot
public static function boot()
{
parent::boot();
static::created(function ($exam) {
$log = new Slog();
$log->ip = request()->ip();
$log->czlx = 'regist';
$log->save();
});
static::deleted(function ($exam) {
$log = new Slog();
$log->ip = request()->ip();
$log->czlx = 'cancel';
$log->save();
});
}
示例5: boot
public static function boot()
{
parent::boot();
static::created(function ($course) {
$log = new Slog();
$log->ip = request()->ip();
$log->kcxh = $course->kcxh;
$log->czlx = 'apply';
$log->save();
});
static::deleted(function ($course) {
$log = new Slog();
$log->ip = request()->ip();
$log->kcxh = $course->kcxh;
$log->czlx = 'revoke';
$log->save();
});
}
示例6: boot
public static function boot()
{
parent::boot();
static::creating(function ($message) {
if ($message->receiver->email != null && $message->receiver->email != "") {
$email = $message->receiver->email;
$data['body'] = "You have a new message from {$message->sender->fullName}.<br>Please click the link below to go to your inbox/read message now<br>";
$data['url']['title'] = 'View Message Now';
$data['url']['link'] = url("inbox/{$message->id}");
$data['title'] = 'You have a new message on CompanyExchange';
Mail::queue('emails.templates.custom', $data, function ($message) use($email) {
$message->from('listings@ng.cx', 'CompanyExchange');
$message->to($email);
$message->subject('New Message on CompanyExchange');
});
}
});
}
示例7: boot
public static function boot()
{
parent::boot();
static::creating(function ($reply) {
if ($reply->receiver->email != null && $reply->receiver->email != "") {
$email = $reply->receiver->email;
$data['body'] = "{$reply->sender->fullName} has just replied to your message on CompanyExchange.<br>Click the link below to view message now<br>";
$data['url']['title'] = 'View Message';
$data['url']['link'] = url("inbox/{$reply->message_id}");
$data['title'] = 'You have a new reply on CompanyExchange';
Mail::queue('emails.templates.custom', $data, function ($message) use($email) {
$message->from('listings@ng.cx', 'CompanyExchange');
$message->to($email);
$message->subject('New Message Reply on CompanyExchange');
});
}
});
}
示例8: boot
/**
* Listen for save event
*
* Saving permalink to history
*/
protected static function boot()
{
parent::boot();
static::saving(function (Article $model) {
if ($model->getOriginal('permalink') !== $model->permalink && !is_null($model->permalink)) {
$articlePermalink = new ArticlePermalink();
$articlePermalink->permalink = $model->permalink;
$articlePermalink->save();
}
return true;
});
static::saved(function (Article $model) {
if ($model->getOriginal('permalink') !== $model->permalink && !is_null($model->permalink)) {
$articlePermalink = ArticlePermalink::findOrFail($model->permalink);
$model->permalinks()->save($articlePermalink);
}
return true;
});
}
示例9: boot
/**
* boot
* observing model
*
*/
public static function boot()
{
parent::boot();
Varian::observe(new VarianObserver());
}
示例10: boot
public static function boot()
{
parent::boot();
Shipment::observe(new ShipmentObserver());
}
示例11: boot
/**
* boot
* observing model
*
*/
public static function boot()
{
parent::boot();
Calendar::observe(new CalendarObserver());
}
示例12: boot
/**
* boot
*
*/
public static function boot()
{
parent::boot();
// Campaign::observe(new CampaignObserver());
}
示例13: boot
public static function boot()
{
parent::boot();
// PersonDocument::observe(new PersonDocumentObserver());
}
示例14: boot
/**
* boot
*
*/
public static function boot()
{
parent::boot();
Price::observe(new PriceObserver());
}
示例15: boot
/**
* boot
* observing model
*
*/
public static function boot()
{
parent::boot();
TransactionLog::observe(new TransactionLogObserver());
}