本文整理汇总了PHP中BaseModel::boot方法的典型用法代码示例。如果您正苦于以下问题:PHP BaseModel::boot方法的具体用法?PHP BaseModel::boot怎么用?PHP BaseModel::boot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BaseModel
的用法示例。
在下文中一共展示了BaseModel::boot方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: boot
protected static function boot()
{
parent::boot();
static::deleting(function ($emoji) {
$emoji->keywords()->delete();
});
}
示例2: boot
/**
* The "booting" method of the model.
*
* @return void
*/
public static function boot()
{
parent::boot();
static::saving(function ($item) {
$item->key = hash('sha512', microtime() . rand());
});
}
示例3: boot
/**
* Model events.
*
* @return void
*/
public static function boot()
{
parent::boot();
static::deleted(function ($user) {
$user->meta()->delete();
});
}
示例4: boot
/**
* 监听创建事件
*/
public static function boot()
{
parent::boot();
self::creating(function ($order) {
$order->order_id = self::get_unique_id(self::$id_prefix);
return true;
});
}
示例5: boot
/**
*
*/
public static function boot()
{
parent::boot();
self::deleting(function ($item) {
$item->load(['values' => function ($q) {
$q->delete();
}]);
});
}
示例6: boot
protected static function boot()
{
parent::boot();
static::deleting(function ($category) {
foreach ($category->media as $block) {
$block->delete();
}
});
}
示例7: boot
static function boot()
{
parent::boot();
Static::observe(new TourSchedulePromoObserver());
Static::observe(new TourScheduleVoucherObserver());
Static::observe(new TourCalculationObserver());
$env = env('ADS_ENGINE');
if (str_is('on', $env)) {
Static::observe(new TourAdsObserver());
}
Static::observe(new TourObserver());
}
示例8: boot
public static function boot()
{
parent::boot();
static::deleting(function ($model) {
foreach ($model->pictures as $picture) {
$path = $picture->path;
$thumbnail = $picture->thumbnail;
if ($picture->delete()) {
File::delete(public_path($path));
File::delete(public_path($thumbnail));
} else {
return false;
}
}
});
}
示例9: boot
public static function boot()
{
parent::boot();
self::deleting(function ($author) {
if ($author->books->count() > 0) {
$html = [];
$html[0] = 'Penulis tidak bisa dihapus karena masih memiliki buku : ';
foreach ($author->books as $key => $book) {
$key = $key + 1;
$html[$key] = "{$key}. {$book->title}";
}
Session::flash('pesan', $html);
return false;
}
});
}
示例10: boot
public static function boot()
{
parent::boot();
//delete associated file
static::deleting(function ($photo) {
try {
$filepath = public_path('files/') . $photo->photo_url;
if (file_exists($filepath)) {
unlink($filepath);
}
} catch (\Exception $e) {
//some error while deleteing
\Log::info('Error deleting: ' . $filepath);
\Log::debug($e);
}
});
}
示例11: boot
/**
* Gallery model events.
*
* @return void
*/
public static function boot()
{
parent::boot();
static::saving(function ($gallery) {
$gallery->filterMetaAttributes($gallery->attributes);
$gallery->saveDefaultAttributes();
});
static::saved(function ($gallery) {
if (empty($gallery::$metaAttributes)) {
return;
}
$gallery->meta()->saveMany($gallery->createMetaList($gallery::$metaAttributes));
});
static::deleted(function ($gallery) {
$gallery->meta()->delete();
});
}
示例12: boot
public static function boot()
{
parent::boot();
self::updating(function ($book) {
$borrowed = DB::table('book_user')->where('book_id', $book->id)->where('returned', 0)->count();
if ($book->amount < $borrowed) {
Session::flash('pesan', "Jumlah buku {$book->title} harus >= {$borrowed}");
return false;
}
});
self::deleting(function ($book) {
$borrowed = DB::table('book_user')->where('book_id', $book->id)->where('returned', 0)->count();
if ($borrowed > 0) {
Session::flash('pesan', "Buku {$book->title} masih dipinjam");
return false;
}
});
}
示例13: boot
public static function boot()
{
parent::boot();
static::deleting(function ($model) {
foreach ($model->steps as $step) {
$picture = $step->picture;
if ($step->delete()) {
File::delete(public_path($picture));
return true;
} else {
return false;
}
}
foreach ($model->foods as $food) {
if ($food->delete()) {
return true;
} else {
return false;
}
}
});
}
示例14: boot
public static function boot()
{
parent::boot();
self::observe(new PageObserver());
}
示例15: boot
public static function boot()
{
parent::boot();
// ShipmentLog::observe(new ShipmentLogObserver());
}