protected static function boot() { parent::boot(); static::deleting(function ($photo) { UploadFile::destroy($photo->file_id); }); }
protected static function boot() { parent::boot(); static::deleting(function ($file) { Storage::delete($file->getAttributeFromArray('file_path')); }); }
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()); }); }