You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Would be good to generate the reverse relationship for fields automatically rather then having to enter them all the time.
In the below you have staff members that are assigned to groups, you can get the group from the staff no problem, however the reverse needs to be added in so you can say give me all the members that belong to this group.
See below example.
<?php namespace Emange\StaffModule\Staff\Group;
use Emange\StaffModule\Staff\Group\Contract\GroupInterface;
use Anomaly\Streams\Platform\Stream\Contract\StreamInterface;
use Emange\StaffModule\Staff\Group\Command\GetGroupStream;
use Anomaly\Streams\Platform\Model\Staff\StaffGroupsEntryModel;
/**
* Class GroupModel
*
* @link http://edi.mange.biz
* @author Emange. <edi@mange.biz>
* @package Emange\StaffModule\Staff\Group
*/
class GroupModel extends StaffGroupsEntryModel implements GroupInterface
{
/**
* Disable timestamps for this model.
*
* @var bool
*/
public $timestamps = false;
/**
* The number of minutes to cache query results.
*
* @var null|false|int
*/
protected $ttl = false;
/**
* The attributes that are
* not mass assignable.
*
* @var array
*/
protected $guarded = [];
/**
* Runtime cache.
*
* @var array
*/
protected $cache = [];
/**
* The cache time.
*
* @var int
*/
protected $cacheMinutes = 99999;
/**
* Get the name.
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Get the slug.
*
* @return string
*/
public function getSlug()
{
return $this->slug;
}
/**
* Get the description.
*
* @return string
*/
public function getDescription()
{
return $this->desciption;
}
/**
* Get the related entry stream.
*
* @return StreamInterface
*/
public function getEntryStream()
{
return $this->dispatch(new GetGroupStream($this));
}
/**
* Get the related entry model name.
*
* @return string
*/
public function getEntryModelName()
{
$stream = $this->getEntryStream();
return $stream->getEntryModelName();
}
/**
* Get related staff.
*
*/
public function getStaff()
{
return $this->staff;
}
/**
* Return the staff relationship.
*
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function staff()
{
return $this->hasMany('Emange\StaffModule\Staff\Staff\StaffModel', 'group_id');
}
}
The text was updated successfully, but these errors were encountered:
Would be good to generate the reverse relationship for fields automatically rather then having to enter them all the time.
In the below you have staff members that are assigned to groups, you can get the group from the staff no problem, however the reverse needs to be added in so you can say give me all the members that belong to this group.
See below example.
The text was updated successfully, but these errors were encountered: