本文整理匯總了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());
}