草庐IT

some_collection

全部标签

php - 需要面向对象设计的建议 : a collection of items

我有一组这样的类:abstractclassCollectionAbsimplementsIterator{publicfunctionGetListAsXml(){...}publicfunctionGetItemsByFilter(criteria:array){...}publicfunctionSort(comparisonFunction){...}publicfunctionAddItem(newItem:CollectionItemAbs);publicfunctionRemoveItem(newItem:CollectionItemAbs);publicfunction

php - Magento 2 : How to get product attributes collection in custom module block file whose status is visible =>yes?

这是我调用产品属性集合的函数我已经获得了已启用产品的产品属性,但我在根据它们自己的可见性过滤它们时遇到问题,即我只想要那些状态设置为可见的产品属性集合来自管理员....classProductListextends\Magento\Framework\View\Element\Template{protected$_attributeFactory;publicfunction__construct(\Magento\Catalog\Model\ResourceModel\Eav\Attribute$attributeFactory){parent::__construct($cont

php - Pool::collect 是如何工作的?

帮助我了解Pool::collect的工作原理。Pool::collect—收集对已完成任务的引用publicvoidPool::collect(Callable$collector)我的假设是:Pool::collect注册一个函数,该函数将在每个\Threaded$task完成后调用。所以,我做了:collect($collector);$pool->submit(newTask);没用。但以下内容确实如此:submit(newTask);$pool->collect($collector);所以,我想Pool::collect所做的是:将$collector附加到之前提交的每个\

php - 在 Laravel Collective 的 Form::text() 中有条件地添加类

我正在为我的表单使用LaravelCollective,每当某个字段的验证失败时,我需要添加一个类。默认字段如下所示:{{Form::text('name',null,['class'=>'form-control'])}}每当验证失败时,我需要将border-danger添加到类中:{{Form::text('name',null,['class'=>'form-controlborder-danger'])}}但我不能简单地在{{Form}}字段中执行@if($errors->has('name'))。有什么简单的方法可以做到这一点吗?我不想做的一件事是这样的:@if($error

php - Laravel Collective HTML5 属性

如何传入HTML5属性,例如:必需、自动对焦...?我可以输入其他具有name="value"的属性,但不能输入仅包含一个单词的属性。 最佳答案 传递带有值的数组作为第三个参数(对于select作为第四个)参数:{!!Form::text('name',null,['required'=>true,'some-param'=>'itsValue','class'=>'some-class'])!!} 关于php-LaravelCollectiveHTML5属性,我们在StackOverf

php - 使用 Laravel Collective 选择输入

{!!Form::select('country',['1'=>'Albania','2'=>'Kosovo','3'=>'Germany','4'=>'France'],null,['class'=>'form-control','placeholder'=>'SelectCountry'])!!}这种类型的输入不采用数组的值,而是采用select中选项的预默认值。在此处输入代码 最佳答案 根据FormCollectivedocumentation,Form::select()的第一个参数是select框的name,第二个是arr

php - 如何返回一个空的 Doctrine_Collection?

我有一个返回Doctrine_Collection的方法,带有whereIn()子句:publicfunctiongetByValues($values){if(!is_array($values))thrownewsfException('Wrongparametertype.Exceptedarray.');returnDoctrine_Query::create()->from('Anomalya')->whereIn('a.value',$values);}但是,当$values为空数组时,此方法返回AnomalyTable中的所有行。这不是意外行为,如Doctrine文档中所

php - 为什么 Wordpress 代码始终具有不常见的 "boolean literal === some dynamic expression"比较部分顺序?

我发现Wordpress代码总是有这样的编码方式:if(false===($value=get_transient('value'))){//thiscoderunswhenthereisnovalidtransientset}我希望它类似于if(($value=get_transient('value'))===false)。Wordpress开发人员是否提到过使用这种PHP语法的任何原因?某处应该有对此的引用,但这种语法很难用谷歌搜索。(我觉得这不属于Wordpress站点,因为它与PHP语法更相关。) 最佳答案 WordPre

php - 拉维尔 5 : Alternative for Eloquent's 'orWhere' method for querying collections

所以我有一个产品集合($this->products),这是我通过模型查询得到的,我想通过它的一些属性值来过滤它。问题是Laravel没有类似orWhere的方法用于集合,就像Eloquent用于查询模型一样。此外,我想使用LIKE%{$searching_for}%通配符,但我不确定如何使用它(如果可能的话)来过滤我的收藏。这是我试图过滤我的集合的代码,显然会抛出orWhere方法不存在的Exception:$products=$this->products->where("field1","LIKE%{$searching_for}%")->orWhere("field2","LI

php - $table->string ('some_text' 之间的区别); & $表->文本 ('some_text' );在 Laravel 中?

关闭。这个问题需要更多focused.它目前不接受答案。想改进这个问题吗?更新问题,使其只关注一个问题editingthispost.关闭7年前。Improvethisquestion有什么区别:$table->string('some_text');和:$table->text('some_text');在Laravel中?拜托,如果你能全面一点。谢谢。