Код: Выделить всё
* @property int $id
* @property int $category_id Country
* @property string $name_product Name product
Код: Выделить всё
Array
(
[0] => [
"category_id" => "3",
"name_product" => "apple",
],
[1] => [
"category_id" => "3",
"name_product" => "ananas",
],
[2] => [
"category_id" => "3",
"name_product" => "apple",
],
)
Код: Выделить всё
public function rules()
{
return [
[['name_product'], 'required'],
[['name_product'], 'string', 'max' => 255],
[['category_id'], 'integer'],
[['category_id'], 'exist', 'skipOnError' => true, 'targetClass' => Category::className(), 'targetAttribute' => ['category_id' => 'id']],
['name_product', 'unique', 'filter' => 'category_id = 3']
];
}