i am getting strange issue, i am using mailwizz extension, i added 4 fields in customer company table, those fields are state,way,mc and subscribers, this is my controller where i am storing data
$company->attributes = (array)request()->getPost($company->getModelName(), []);
$company->customer_id = (int)$lastID;
$company->name = $request->getPost('companyName');
$company->address_1 = $request->getPost('houseNumber');
$company->address_2 = $request->getPost('street');
$company->zip_code = $request->getPost('zipCode');
$company->city = $request->getPost('city');
$company->state = $request->getPost('state');
$company->country_id = $request->getPost('country');
$company->way = $request->getPost('way');
$company->mc = implode(',',$request->getPost('mc'));
$company->subscribers = $request->getPost('subscribers');
try {
$company->save(false);
} catch (Exception $e) {
print_r($company->getErrors());
die;
}
and this is my model file
class CustomerCompany extends ActiveRecord
{
/**
* @return string
*/
public $state;
public $way = '';
public $mc = '';
public $subscribers = '';
public function tableName()
{
return '{{customer_company}}';
}
/**
* @return array
*/
public function rules()
{
$rules = [
['name, country_id, address_1, city, zip_code', 'required', 'on' => 'insert, update, register'],
['name, vat_number', 'length', 'max' => 100],
['website', 'length', 'max' => 255],
['website', 'url'],
['country_id, zone_id', 'numerical', 'integerOnly' => true, 'min' => 1],
['address_1, address_2, city,state,mc,subscribers,country_id', 'length', 'max' => 255],
['zone_name', 'length', 'max' => 150],
['zip_code', 'length', 'max' => 10],
['phone, fax', 'length', 'max' => 32],
['type_id', 'exist', 'attributeName' => null, 'className' => CompanyType::class],
['country_id', 'exist', 'attributeName' => null, 'className' => Country::class],
['zone_id', 'exist', 'attributeName' => null, 'className' => Zone::class],
['phone, fax', 'match', 'pattern' => '/[0-9s-]+/'],
//['state,mc,subscribers,way','safe']
];
return CMap::mergeArray($rules, parent::rules());
}
}
can anyone please help me why i am not able add or update those 4 new field, i am using mailwizz, which is built in yii2