Example #1
0
 protected static function boot()
 {
     parent::boot();
     static::deleting(function ($photo) {
         UploadFile::destroy($photo->file_id);
     });
 }
Example #2
0
 protected static function boot()
 {
     parent::boot();
     static::deleting(function ($file) {
         Storage::delete($file->getAttributeFromArray('file_path'));
     });
 }
Example #3
0
 protected static function boot()
 {
     parent::boot();
     // static::updating(function ($product) {
     //     $changed = $product->isDirty() ? $product->getDirty() : false;
     //     if ($changed && $changed['options']) {
     //         // maintain stock
     //         print_r($changed['options']);
     //     }
     // });
     static::deleting(function ($product) {
         $ids = ProductPhoto::select()->where('product_id', '=', $product->id)->lists('id');
         ProductPhoto::destroy($ids->toArray());
     });
 }