当前位置: 首页>>代码示例>>PHP>>正文


PHP Model::boot方法代码示例

本文整理汇总了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');
     });
 }
开发者ID:creativelittledots,项目名称:wp-kit-core,代码行数:12,代码来源:Term.php

示例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');
     });
 }
开发者ID:creativelittledots,项目名称:wp-kit-core,代码行数:12,代码来源:Taxonomy.php

示例3: boot

 protected static function boot()
 {
     parent::boot();
     static::deleting(function ($category) {
         self::where('parents', 'LIKE', $category->parents . $category->id . '/%')->delete();
     });
 }
开发者ID:kshar1989,项目名称:dianpou,代码行数:7,代码来源:Category.php

示例4: boot

 public static function boot()
 {
     parent::boot();
     Category::creating(function ($category) {
         $category->slug = $category->generateSlug();
     });
 }
开发者ID:fajarekos,项目名称:elearning,代码行数:7,代码来源:Category.php

示例5: boot

 public static function boot()
 {
     parent::boot();
     static::created(function ($topic) {
         SiteStatus::newReply();
     });
 }
开发者ID:yhbyun,项目名称:l5-forum,代码行数:7,代码来源:Reply.php

示例6: boot

 protected static function boot()
 {
     parent::boot();
     static::deleting(function ($project) {
         $project->tasks()->delete();
         $project->invoices()->delete();
     });
 }
开发者ID:titus-toia,项目名称:treabar,代码行数:8,代码来源:Project.php

示例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);
     });
 }
开发者ID:creativelittledots,项目名称:wp-kit-core,代码行数:13,代码来源:Comment.php

示例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);
     });
 }
开发者ID:FebriPratama,项目名称:pop,代码行数:9,代码来源:Upload.php

示例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;
         }
     });
 }
开发者ID:Aliqhuart,项目名称:puzzle-wp,代码行数:9,代码来源:Order.php

示例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);
         }
     });
 }
开发者ID:sarthak96agarwal,项目名称:quoterr.me,代码行数:13,代码来源:Tag.php

示例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), '-'));
         }
     });
 }
开发者ID:sarthak96agarwal,项目名称:quoterr.me,代码行数:13,代码来源:Author.php

示例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;
     });
 }
开发者ID:kolexndr,项目名称:mustard,代码行数:17,代码来源:NonSequentialIdModel.php

示例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');
     });
 }
开发者ID:creativelittledots,项目名称:wp-kit-core,代码行数:18,代码来源:Post.php

示例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);
     });
 }
开发者ID:pombredanne,项目名称:licenser-7,代码行数:13,代码来源:Expiration.php

示例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;
         }
     });
 }
开发者ID:pombredanne,项目名称:licenser-7,代码行数:18,代码来源:Notification.php


注:本文中的Model::boot方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。