for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace app\api\models;
use roaresearch\yii2\roa\ResourceSearch;
use roaresearch\yii2\workflow\models\Stage;
use yii\data\ActiveDataProvider;
class CreditSearch extends Credit implements ResourceSearch
{
/**
* @inhertidoc
*/
public function attributes()
return array_merge(parent::attributes(), ['activeStage']);
}
protected $autogenerateInitialWorklog = false;
public function rules()
return [
[['created_by'], 'integer'],
[
['activeStage'],
'each',
'allowMessageFromRule' => true,
'rule' => [
'integer',
'message' => '{value} is not an integer',
],
];
public function search(
array $params,
?string $formName = ''
): ?ActiveDataProvider {
$this->load($params, $formName);
if (!$this->validate()) {
return null;
$class = get_parent_class();
return new ActiveDataProvider([
'query' => $class::find()
->joinWith('activeWorkLog')
->andFilterWhere([
'credit.created_by' => $this->created_by,
created_by
app\api\models\CreditSearch
__get
'activeWorkLog.stage_id' => $this->activeStage,
activeStage
])
]);