本文整理汇总了PHP中Model::boot方法的典型用法代码示例。如果您正苦于以下问题:PHP Model::boot方法的具体用法?PHP Model::boot怎么用?PHP Model::boot使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Model
的用法示例。
在下文中一共展示了Model::boot方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: boot
/**
* Boot process.
*
* @return Void
*/
protected static function boot()
{
parent::boot();
static::addGlobalScope('order', function (Builder $builder) {
$builder->orderBy('name', 'asc');
});
}
示例2: boot
/**
* Boot process.
*
* @return Void
*/
protected static function boot()
{
parent::boot();
static::addGlobalScope('order', function (Builder $builder) {
$builder->join('terms as t', 't.term_id', '=', 'term_taxonomy.term_id')->orderBy('t.name', 'asc');
});
}
示例3: boot
protected static function boot()
{
parent::boot();
static::deleting(function ($category) {
self::where('parents', 'LIKE', $category->parents . $category->id . '/%')->delete();
});
}
示例4: boot
public static function boot()
{
parent::boot();
Category::creating(function ($category) {
$category->slug = $category->generateSlug();
});
}
示例5: boot
public static function boot()
{
parent::boot();
static::created(function ($topic) {
SiteStatus::newReply();
});
}
示例6: boot
protected static function boot()
{
parent::boot();
static::deleting(function ($project) {
$project->tasks()->delete();
$project->invoices()->delete();
});
}
示例7: boot
/**
* Boot process.
*
* @return Void
*/
protected static function boot()
{
parent::boot();
static::addGlobalScope('order', function (Builder $builder) {
$builder->orderBy('comment_date', 'desc');
$builder->where('comment_approved', 1);
});
}
示例8: boot
public static function boot()
{
parent::boot();
// Deleting an upload record should delete the file as well
static::deleting(function ($upload) {
$file = public_path() . '/' . $upload->path . '/' . $upload->filename;
File::delete($file);
});
}
示例9: boot
public static function boot()
{
parent::boot();
static::creating(function (Order $order) {
if (!$order->user_id && \Auth::check()) {
$order->user_id = \Auth::user()->id;
}
});
}
示例10: boot
/**
* @return void
* @static
*/
protected static function boot()
{
parent::boot();
static::validating(function (Tag $tag) {
if (!$tag->slug) {
$tag->slug = str_slug($tag->name);
}
});
}
示例11: boot
/**
* @return void
* @static
*/
protected static function boot()
{
parent::boot();
static::validating(function (Author $author) {
if (!$author->slug) {
$author->slug = strtolower(trim(str_slug($author->name), '-'));
}
});
}
示例12: boot
/**
* Find and use an unused non-sequential ID for a record, as part of a
* model's creation. ID will be a 32-bit unsigned integer of 10 characters
* in length.
*
* @return void
*/
protected static function boot()
{
parent::boot();
self::creating(function ($model) {
do {
$id = mt_rand(pow(10, 9), pow(2, 32) - 1);
} while (self::find($id));
$model->{$model->getKeyName()} = $id;
});
}
示例13: boot
/**
* Boot process.
*
* @return Void
*/
protected static function boot()
{
parent::boot();
$model = new static();
if ($model->getPostType()) {
static::addGlobalScope('post_type', function (Builder $builder) use($model) {
$builder->where('post_type', $model->getPostType());
});
}
static::addGlobalScope('order', function (Builder $builder) {
$builder->orderBy('post_date', 'desc');
});
}
示例14: boot
public static function boot()
{
parent::boot();
static::creating(function ($expiration) {
do {
$token = sha1(uniqid() . time());
$count = Expiration::where('token', $token)->count();
} while ($count != 0);
$expiration->token = $token;
$minutes = intval(Setting::key('link_duration')->first()->value) > 0 ? intval(Setting::key('link_duration')->first()->value) : 60;
$expiration->expiration = Carbon::now()->addMinutes($minutes);
});
}
示例15: boot
public static function boot()
{
parent::boot();
static::created(function ($notification) {
switch ($notification->type) {
case 'new_prospect':
$prospect = Prospect::find($notification->type_id);
$user = User::find($notification->user_id);
Clickatell::send("Nuevo Interesado en " . $prospect->type . " - Nombre: " . $prospect->name . " Email: " . $prospect->email . " Tel.: " . $prospect->phone, $user->phone);
$data = ['name' => $prospect->name, 'email' => $prospect->email, 'phone' => $prospect->phone];
Mail::queue('emails.notify.new-prospect', $data, function ($message) use($user) {
$message->from('noreply@mlmfunnel.com', 'MLMfunnel');
$message->to($user->email, $user->full_name)->subject('Nuevo prospecto! - MLMfunnel');
});
break;
}
});
}