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


PHP BaseModel::boot方法代码示例

本文整理汇总了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();
     });
 }
开发者ID:andela-gjames,项目名称:Emoji-API,代码行数:7,代码来源:Emoji.php

示例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());
     });
 }
开发者ID:AccessibilityNL,项目名称:User-Testing-Tool,代码行数:12,代码来源:Organization.php

示例3: boot

 /**
  * Model events.
  *
  * @return void
  */
 public static function boot()
 {
     parent::boot();
     static::deleted(function ($user) {
         $user->meta()->delete();
     });
 }
开发者ID:estebanmatias92,项目名称:pull-automatically-galleries,代码行数:12,代码来源:User.php

示例4: boot

 /**
  * 监听创建事件
  */
 public static function boot()
 {
     parent::boot();
     self::creating(function ($order) {
         $order->order_id = self::get_unique_id(self::$id_prefix);
         return true;
     });
 }
开发者ID:Jv-Juven,项目名称:carService,代码行数:11,代码来源:AgencyOrder.php

示例5: boot

 /**
  *
  */
 public static function boot()
 {
     parent::boot();
     self::deleting(function ($item) {
         $item->load(['values' => function ($q) {
             $q->delete();
         }]);
     });
 }
开发者ID:donny5300,项目名称:translations,代码行数:12,代码来源:Language.php

示例6: boot

 protected static function boot()
 {
     parent::boot();
     static::deleting(function ($category) {
         foreach ($category->media as $block) {
             $block->delete();
         }
     });
 }
开发者ID:sonoftheweb,项目名称:laravel-angular-cms,代码行数:9,代码来源:MediaCategory.php

示例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());
 }
开发者ID:erickmo,项目名称:CapcusAPI,代码行数:12,代码来源:Tour.php

示例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;
             }
         }
     });
 }
开发者ID:Kangaroos,项目名称:oneshike,代码行数:16,代码来源:DraftArticle.php

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

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

示例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();
     });
 }
开发者ID:estebanmatias92,项目名称:pull-automatically-galleries,代码行数:22,代码来源:Gallery.php

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

示例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;
             }
         }
     });
 }
开发者ID:Kangaroos,项目名称:oneshike,代码行数:22,代码来源:DraftCookbook.php

示例14: boot

 public static function boot()
 {
     parent::boot();
     self::observe(new PageObserver());
 }
开发者ID:xiaohulidudu,项目名称:laravel-blog,代码行数:5,代码来源:Page.php

示例15: boot

 public static function boot()
 {
     parent::boot();
     // ShipmentLog::observe(new ShipmentLogObserver());
 }
开发者ID:ThunderID,项目名称:SHOP-API,代码行数:5,代码来源:ShipmentLog.php


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