Welcome, Guest
Username: Password: Remember me

TOPIC: Relation-field-name declaration

Relation-field-name declaration 07 Feb 2017 22:33 #15002

  • vlemos
  • vlemos's Avatar
  • Online
  • Elite Member
  • Posts: 295
  • Thank you received: 41
  • Karma: 21
Hello Admin, I am currently working on a project in which everything is separated by company, including pivots. I have found the syncRelation function and added:
	$model->save(array(
		'company_id' => $item->company_id,
		$relation->pivotLocalKey => (int)$this->getId(),
		$relation->pivotForeignKey => (int)$value
	));

It works but lacks the elegance of the code around it. Would like to add a way to pass extra data in the relationship declaration.
	$this->belongsToMany('groups', // name
		'groups', // foreignModelClass
		'id', // localKey
		'id', // foreignKey,
		'usergroups', // pivotModelClass,
		'user_id', // pivotLocalKey
		'group_id', // pivotForeignKey
		'company_id' // pivotCompanyKey ************
	);
Where can I find the relation-field-name declaration?

Thanks
vlemos

Note: final request for today
:cheer:
The administrator has disabled public write access.

Relation-field-name declaration 08 Feb 2017 00:52 #15003

  • vlemos
  • vlemos's Avatar
  • Online
  • Elite Member
  • Posts: 295
  • Thank you received: 41
  • Karma: 21
Hello Admin, found what I was looking for. Thx
The administrator has disabled public write access.
Time to create page: 0.087 seconds

Get Started